'In Activty_create
PrefDialog.Initialize(Activity, "Editable Row", 300dip, 300dip)
PrefDialog.LoadFromJson(File.ReadString(File.DirAssets, "Customers.json"))
Sub B4XTable5_CellLongClicked (ColumnId As String, RowId As Long)
Dim RowData As Map = B4XTable5.GetRow(RowId)
ShowDialog5(RowData,RowId)
End Sub
Private Sub ShowDialog5(Item As Map, RowId As Long)
Wait For (PrefDialog.ShowDialog(Item, "OK", "CANCEL")) Complete (Result As Int)
If Result = xui.DialogResponse_Positive Then
Dim params As List
params.Initialize
params.AddAll(Array( Item.Get("Name"), Item.Get("Company"), Item.Get("Address") )) 'keys based on the template json file
If RowId = 0 Then 'new row
' insert not undertaken in this call
' B4XTable5.sql1.ExecNonQuery2($"INSERT INTO data VALUES("", ?, ?, ?, ?)"$, params)
' B4XTable5.ClearDataView
Else
params.Add(RowId)
'first column is c0. We skip it as this is the "edit" column
B4XTable5.sql1.ExecNonQuery2("UPDATE data SET c1 = ?, c2 = ?, c3 = ? WHERE rowid = ?", params)
B4XTable5.Refresh
sql.ExecNonQuery2("UPDATE customers SET LastName = ? , Company = ?, Address = ? WHERE rowid = ?" , Array As Object(Item.GetValueAt(1), Item.GetValueAt(2),Item.GetValueAt(3), RowId))
End If
End If
End Sub