based on Erel's example, i added checkbox to B4Xtable column and name it 'Select' now i want to iterate thru table rows to get checked-only rows. how to do this?
For i = 1 To CheckColumn.CellsLayouts.Size - 1 'add custom check box to table
'Sleep(0)
Dim pnl As B4XView = CheckColumn.CellsLayouts.Get(i)
Dim ColCheckBox As CheckBox
ColCheckBox.Initialize("")
St.SetButtonTintList(ColCheckBox,Colors.Gray,SysDeclare.COLOR_DARK_NAVY)
pnl.AddView(ColCheckBox, 5dip, 5dip, CheckColumn.Width - 10dip, tblPhoneContacts.RowHeight - 10dip)
Next
Sub btn_Click
For i = 0 To B4XTable1.VisibleRowIds.Size - 1
Dim RowId As Long = B4XTable1.VisibleRowIds.Get(i)
Dim pnl As B4XView = CheckColumn.CellsLayouts.Get(i + 1) '+1 because first cell is a header
Dim ColCheckBox As CheckBox = pnl.GetView(1)
If RowId > 0 Then
Dim row As Map = B4XTable1.GetRow(RowId)
If ColCheckBox.Checked Then
Log($"Checked rowid ${RowId} "$)
' Log($"rowid ${RowId} ${row.Get("Name")}"$) 'Name is header of another column to display
End If
End If
Next
End Sub
Hi @Mostez: If you uncomment the line I have commented in the code, the line will be used. If you have another column named Name for example, it will show you the content of each based on the rowid. You can use another col name if you want.
For Each rowid As Long In TableStyle.SelectedLines.Keys
Dim row As Map = tblPhoneContacts.GetRow(rowid)
Cont.CompanyName = row.Get("CompanyName")
Cont.ContactName = row.Get("ContactName")
...
Next