#2817 Directly edit fwt Table and Disable Column Sorting

small_petit Mon 14 Dec 2020

Hello, please I want to know if it is possible to edit Fantom FWT Table cells directly. As in double-clicking and entering new cell values.

Also, can I please know how to disable the sorting behaviour on column header clicks?

Thank you.

small_petit Tue 15 Dec 2020

Well, I could only let a dialog open, so I can enter the new value. Here is the code:

table.onMouseDown.add |Event e| 
    {
        if (e.count == 2)
        {
            row := table.rowAt(e.pos)
            col := table.colAt(e.pos)
            ans := Dialog.openPromptStr(e.window, "Enter new value:")
            model.data[row][col] = ans.toInt
            table.refreshAll				
        }
}

But I really wish I could just edit the values directly as in spreadsheet programs where you double-click, and do your edit right away.

I am still working out how to turn the automatic column sorting behaviour off.

Thank you.

SlimerDude Tue 15 Dec 2020

Hey small_petit, I missed this yesterday!

As you've surmised, there is no table edit feature in fwt - I'm afraid it's just not that advanced. Your prompt popup on click is the best way.

I don't think there's an inbuilt way to disable sorting either. The best I can think of is overriding TableModel.sortCompare() to always return the same desired ordering. That way, when the table is sorted, the order doesn't change.

small_petit Wed 16 Dec 2020

Thanks SlimerDude.

In my Table model class, I did:

override Int sortCompare(Int col, Int row1, Int row2)
{
    return 0
}

And sure, my table maintains the sort order of the way I inserted values.

Thank you once again for your help.

Login or Signup to reply.