Android Question Multiple action on B4XTable

ProjectGroup19

Active Member
Licensed User
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?
 
Solution
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

Expert
Licensed User
Longtime User
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
 
Upvote 0
Solution

ProjectGroup19

Active Member
Licensed User
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?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
i want to delete based on another column accountID(b4xtable coolumn) instead of rowid.
Here it is:
B4X:
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.
 
Upvote 0

ProjectGroup19

Active Member
Licensed User
Here it is:
B4X:
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.
Thanks @Mahares
This worked as expected☺️
 
Upvote 0
Top