Bug? Incorrect table sorting after reset

JdV

Active Member
Licensed User
Longtime User
Hello

I don't know if this is a bug but see attached program.

The table is filled with numbers 0 to 100
1695977288488.png

Click on the column header to sort the numbers from 100 to 0
Click the Reset button
The table is cleared and then re-filled with numbers 0 to 100
The column still indicates that it's sorting from highest to lowest number
1695977234673.png


Is this a bug?
Is TableView1.items.clear the correct way to effectively reset a table?
Is there a way to find out which column is being used to sort?

Regards

Joe
 

Attachments

  • TableTest.zip
    2 KB · Views: 62

agraham

Expert
Licensed User
Longtime User
Yes, I would regard that as a minor bug. However you can easily overcome it
B4X:
Sub Button1_Click
    Dim l As List
    l.Initialize
    TableView1.Items = l
    FillTable
End Sub

Sub FillTable
    For i=0 To 100
        Dim row() As Object = Array(Rnd(0, 100))
        TableView1.Items.Add(row)   
    Next   
End Sub
 

JdV

Active Member
Licensed User
Longtime User
That's a beautifully simple solution. Thanks.

Is there no way to find out what column (if any) is being sorted so that when the table is refilled, it can be sorted again by that column?
 

agraham

Expert
Licensed User
Longtime User
Is there no way to find out what column (if any) is being sorted
Not that I can see without poking around inside it with JavaObject and I'm not sure even then.
when the table is refilled, it can be sorted again by that column
This should do that
B4X:
Sub Button1_Click
    TableView1.Items.Clear
    FillTable
    Dim jo As JavaObject = TableView1
    jo.RunMethod("sort", Null)
End Sub

Sub FillTable
    For i=0 To 100
        Dim row() As Object = Array(Rnd(0, 100))
        TableView1.Items.Add(row)  
    Next  
End Sub
 
Top