Greetings Family,
Please, i have been able to multiselect rows on b4xtable using B4XTableSelections. How can i perform multiple actions (delete, edit, etc) on these selected rows?
Here is the code to delete the selected rows from the in-memory table:
B4X:
Sub btn_Click
If XSelections.IsSelected = False Then
Log("Nothing is selected")
Else
For Each rowid As Long In XSelections.SelectedLines.Keys
B4XTable1.sql1.ExecNonQuery2("DELETE FROM data WHERE rowid = ?", Array (rowid)) 'data is the in-memory table
Next
B4XTable1.Refresh
End If
End Sub
Here is the code to delete the selected rows from the in-memory table:
B4X:
Sub btn_Click
If XSelections.IsSelected = False Then
Log("Nothing is selected")
Else
For Each rowid As Long In XSelections.SelectedLines.Keys
B4XTable1.sql1.ExecNonQuery2("DELETE FROM data WHERE rowid = ?", Array (rowid)) 'data is the in-memory table
Next
B4XTable1.Refresh
End If
End Sub
Here is the code to delete the selected rows from the in-memory table:
B4X:
Sub btn_Click
If XSelections.IsSelected = False Then
Log("Nothing is selected")
Else
For Each rowid As Long In XSelections.SelectedLines.Keys
B4XTable1.sql1.ExecNonQuery2("DELETE FROM data WHERE rowid = ?", Array (rowid)) 'data is the in-memory table
Next
B4XTable1.Refresh
End If
End Sub
@Mahares, thank you for your response. It worked great but let's say i want to delete based on another column accountID(b4xtable coolumn) instead of rowid. How do i do that?
Sub btn_Click
If XSelections.IsSelected = False Then
Log("Nothing is selected")
Else
For Each rowid As Long In XSelections.SelectedLines.Keys
Dim RowData As Map = B4XTable1.GetRow(rowid)
Dim MyAccID As String
MyAccID = RowData.Get("accountID") ' If accountID is 1st col in B4XTable then below line shows c0, if 2nd in B4XTable then below c1
B4XTable1.sql1.ExecNonQuery2("DELETE FROM data WHERE c0 = ?", Array (MyAccID)) 'data is the in-memory table
Log(MyAccID)
Next
B4XTable1.UpdateTableCounters
End If
End Sub
In the memory table the columns of B4XTable are referred to as c0, c1, c2, etc.
Sub btn_Click
If XSelections.IsSelected = False Then
Log("Nothing is selected")
Else
For Each rowid As Long In XSelections.SelectedLines.Keys
Dim RowData As Map = B4XTable1.GetRow(rowid)
Dim MyAccID As String
MyAccID = RowData.Get("accountID") ' If accountID is 1st col in B4XTable then below line shows c0, if 2nd in B4XTable then below c1
B4XTable1.sql1.ExecNonQuery2("DELETE FROM data WHERE c0 = ?", Array (MyAccID)) 'data is the in-memory table
Log(MyAccID)
Next
B4XTable1.UpdateTableCounters
End If
End Sub
In the memory table the columns of B4XTable are referred to as c0, c1, c2, etc.