B4XTableSelections extends B4XTable and adds new selection modes:
SINGLE_CELL_TEMP - this is the built-in selection mode. Unlike the other selection modes it disappears automatically.
SINGLE_CELL_PERMANENT - selection of a single cell.
SINGLE_LINE_PERMANENT - selection of a single line.
MULTIPLE_CELLS - selection of multiple cells.
MULTIPLE_LINES - selection of multiple lines
Initialize B4XTableSelections and set the mode:
XSelections.Initialize(B4XTable1) XSelections.Mode = XSelections.MODE_SINGLE_CELL_TEMP
Sub B4XTable1_CellClicked (ColumnId As String, RowId As Long) XSelections.CellClicked(ColumnId, RowId) End Sub Sub B4XTable1_DataUpdated XSelections.Refresh End Sub
In lines mode:
For Each rowid As Long In XSelections.SelectedLines.Keys Next
For Each rowid As Long In XSelections.SelectedLines.Keys Dim cols As List = XSelections.SelectedLines.Get(rowid) For Each col As String In cols 'cell is defined by (rowid, col) Next Next
You can also make selections programmatically by modifying SelectedLines collection and calling Refresh.
The class is included in the attached B4J example.
V1.04 - Fixes an issue with hidden columns.
V1.03 - New SelectedTextColor field. Note that it depends on B4XTable v1.21+ (https://www.b4x.com/android/forum/t...sortable-searchable-customizable-table.102322).
V1.02 - Bug fix. New IsSelected property.
New FirstSelectedRowId and FirstSelectedColumnId methods. Especially useful in the single mode selections.
Depends on B4XCollections.
V1.01 - New AutoRemoveInvisibleSelections field. When True selections are removed automatically when the selected lines or cells are not visible.
54 KB Views: 107