Android Question Can B4xTable columns be a accessed by integer

Is it possible to access a column by an integer id instead of the title string?

The tutorial seems to indicate it's possible but I am unable to find any examples

The id equals to the title by default (can be changed) or am I understanding this incorrectly?

I am trying to write the code as
B4X:
If Table1(row,Col) = condition then
    pnl.Color = xui.Color_Cyan
end if

Hopefully this makes sense


Thanks
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Mahares

Expert
Licensed User
Longtime User
ut the ID is a string, I need it as the number for addressing the column in a loop
Are you looking to color the cell panel with a certain color based on the numeric content of that cell. if so, it can be done. Jack, you might want to show the code you are trying to manipulate and explain exactly and in detail what you want to achieve. I think you will get more precise help and less conjecture.
 
Upvote 0
Are you looking to color the cell panel with a certain color based on the numeric content of that cell. if so, it can be done. Jack, you might want to show the code you are trying to manipulate and explain exactly and in detail what you want to achieve. I think you will get more precise help and less conjecture.
Thanks for the reply
It is based on a comparison of 2 cells in a row, not adjacent

I have found a workaround, it's not elegant but it does work. I do a comparison early in the data loading and store any differences in an array

B4X:
Sub SetCellColor

    Dim c As B4XTableColumn
    For x = 1 To 36
        Dim i As Int =0
    For Each c As B4XTableColumn In B4XTable1.VisibleColumns
        Dim pnl As B4XView = c.CellsLayouts.Get(x)
        If Errors(x,i)<>"" Then
            pnl.Color = xui.Color_Cyan                   
        End If
    i=i+1
    Next
    Next
End Sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
If you are comparing the contents of 2 cells in a given row not necessarily adjacent, you can always add another column to the B4XTable that represents the difference between those 2 cells you are comparing. Based on the value of the difference, you can then highlight the row or any given cell in that row. No need to respond if this answer is irrelevant to your situation.
 
Upvote 0
If you are comparing the contents of 2 cells in a given row not necessarily adjacent, you can always add another column to the B4XTable that represents the difference between those 2 cells you are comparing. Based on the value of the difference, you can then highlight the row or any given cell in that row. No need to respond if this answer is irrelevant to your situation.
Thank you Mahares, yes this would work, I did in fact take a similar approach with a different problem and hiding the column. It would be a lot easier if I could in fact access a cell directly with (row,cell) syntax rather than by the column's title especially in my case where the titles are generated by the code and there often is titles of the same name. Such is life, maybe at a later date this will be available

Thanks again for your help
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
It would be a lot easier if I could in fact access a cell directly with (row,cell) syntax rather than by the column's title

Of course it can be done with col,row combination using the Flexible Table. When you get a chance, check out Flexible Table class:
There is a complete example using the latest table class: 3.30 on the far right of the first post. You can import data into it from SQLite, CSV, etc. It is also vertically scrollable. You cannot do it with B4XTable because the rowids , although unique, can change from display to another and you have to have column names or ids.
 
Upvote 0
Top