Android Question B4XTable - Row header and running Nr

Noelkman

Member
Licensed User
Longtime User
Is it possible to have a running Nr as a row header no matter if sorted whatever way always starting with '1' ?
I was playing a while with the VOID column type but was not able to create ?
Does someone have already a technique?
 

Mahares

Expert
Licensed User
Longtime User
Have it ?
Never mind.
1. You are posting in the wrong forum. You should post in the questions forum.
2. You do not tell us what Nr is.
3. You did not tell us what your solution is to help the others. I use B4XTable. I like to learn more about it.
 
Last edited:
Upvote 0

Noelkman

Member
Licensed User
Longtime User
I was a bit to hectic when writing to the wrong forum.
Ok, here we go.
I was asking for a running Number like row number that does not need to be entered but displayed at the top of the row.
No matter of sorting this number will not be sorted. It is just a info column and I needed that.

My solution is as follows:
Snippet:
'define the column
Dim LNColumn As B4XTableColumn
LNColumn = B4XTable1.AddColumn("Nr", B4XTable1.COLUMN_TYPE_VOID)
LNColumn.Width = 40dip


'numbering part
Sub B4xTable1_DataUpdated
    
    'partially taken from Erels Example of having custom columns
        
    Dim iNr As Int = B4XTable1.RowsPerPage * (B4XTable1.CurrentPage - 1) + 1
        
    For i = 0 To B4XTable1.VisibleRowIds.Size - 1
        Dim RowId As Long = B4XTable1.VisibleRowIds.Get(i)
        Dim lbl As B4XView = LNColumn.CellsLayouts.Get(i + 1)
        Dim slbl As Label = lbl.GetView(0) 'ImageView will be the 2nd child of the panel. The built-in label is the first.
        If RowId > 0 Then 'if you take this out it is numbering all rows down even if there is no data
            slbl.Text = iNr
        End If
        iNr = iNr + 1
    Next
End  Sub
 
Upvote 0
Top