B4J Question TableView Sort

tomazc

Member
Licensed User
Longtime User
Is it possible to sort formated datetime field in TableView (by clicking a column title) and how can I align data (left/right). I know i can use object instead of string but I do not know how to select sort field in object.


Thanks in advance!


Regards, Tomaz
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The internal sort feature will not work properly with objects.

You can change the alignment of columns with this code:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.Show
   MainForm.RootPane.LoadLayout("1")
   For i = 1 To 10
     TableView1.Items.Add(Array(i, i, i))
   Next
   SetColumnStyle(TableView1, 0, "-fx-alignment: CENTER;")
   SetColumnStyle(TableView1, 1, "-fx-alignment: CENTER-RIGHT;")
End Sub

Sub SetColumnStyle(table As TableView, ColumnIndex As Int, Style As String)
   Dim jo As JavaObject = table
   jo.RunMethodJO("getColumns", Null).RunMethodJO("get", Array(ColumnIndex)).RunMethod("setStyle", Array(Style))
End Sub
 
Upvote 0
Top