Android Question [B4XTable] Knowing the clicked column

vecino

Well-Known Member
Licensed User
Longtime User
Hi, this is probably a silly question, but I can't find the answer.
If the user clicks on a row of a B4XTable, how can I know which column he clicked on?
In "_CellClicked(ColumnId As String, RowId As Long)" it returns the column name and the row number, shouldn't it be the column number?

B4X:
Private Sub tbLecturas_CellClicked (ColumnId As String, RowId As Long)
    Log(ColumnId  &" - "& RowId)
End Sub

*** Service (starter) Create ***
Using FileProvider? false
** Service (starter) Start **
** Activity (main) Resume **
** Activity (main) Resume **
Última - 2
Última - 1
Contador - 1
Contador - 2
Contador - 3
Contador - 4
Contador - 5
** Activity (main) Pause, UserClosed = true **
 

vecino

Well-Known Member
Licensed User
Longtime User
I see that with this code it shows: c1, c2, c3, etc. depending on the column pressed.
Is it safe to use that method to know the column where the user has tapped?

B4X:
Private Sub tbLecturas_CellClicked (ColumnId As String, RowId As Long)
  Dim tc As B4XTableColumn = tbLecturas.GetColumn( ColumnId )
  Log( tc.SQLID )

c2
c0
c0
c1
c2
c3
c4
c5
c6
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Is it safe to use that method to know the column where the user has tapped?
Let me add to what Willy wrote:
Yes, safe.
B4X:
Private Sub B4XTable1_CellClicked (ColumnId As String, RowId As Long)
  Dim tc As B4XTableColumn = B4XTable1.GetColumn( ColumnId )
  Log( tc.SQLID )  'In the in memory database table the cols are referred to as c0, c1, c2, etc
  Log( tc.id )     'header name for the given column
  Log(tc.Title)  'by default the title is the same as the id. Therefore,  tc.id same as tc.Title
End Sub
If you are running a query involving the in memory table which is called data, you have to use c0, c1 and so on
 
Upvote 2

vecino

Well-Known Member
Licensed User
Longtime User
Thanks, friends, with this information I have another question that I will ask in a new thread.
But that will be tomorrow, I'm tired today ?
 
Upvote 0
Top