B4J Question SOLVED B4XTable Issue with alignment after using 'Search' option

Yafuhenk

Active Member
Licensed User
Longtime User
I use the following subs to align and format the text and values in the B4XTable columns
B4X:
Sub SetColumnAlignmentAndFormat(columnID As String)
   
    '//set alignment and
    Dim Column As B4XTableColumn = B4XTable1.GetColumn(columnID)
    Dim Alignment As String
    For i = 1 To Column.CellsLayouts.Size - 1
        Dim Pnl As B4XView = Column.CellsLayouts.Get(i)
        If Column.ColumnType = 2 Then '2 is numeric
            Dim Lbl As B4XView = Pnl.GetView(0)
            If Lbl.Text <> "" Then
                'remove comma to get correct format.
                'will cause an issue with US country settings.
                'in that case change to Lbl.Text = Lbl.Text.Replace(".","")
                Lbl.Text = Lbl.Text.Replace(",","")
                Lbl.Text =Formatter.Format(Lbl.Text)
            End If
            Alignment = "RIGHT"
        Else
            Alignment = "LEFT"
        End If
        Pnl.GetView(0).SetTextAlignment("CENTER", Alignment)
    Next
End Sub

Sub B4XTable1_DataUpdated
   
    '//update the table
    'align and format the columns
    For i = 0 To ColumnTitles.Size - 1
        SetColumnAlignmentAndFormat(ColumnTitles.Get(i))
    Next
   
    'get the sum of the column in case content in numeric
    For i = 0 To ColumnTypes.Size - 1
        If ColumnTypes.Get(i) = 2 Then '2 = numeric
            SetColumnSum(ColumnTitles.Get(i))
        End If   
    Next
    '\\
   
End Sub
When the table is created this gives the expected result but when I use the Search option I get a center alignment of the tables containing text
Any idea what I do wrong?
1.png
 
Last edited:
Top