Hi
i am working on b4a projects, its based on >> https://www.b4x.com/android/forum/threads/b4x-cross-platform-editable-b4xtable-form-example.104766/
i am try to add time-24 hour format, also update json file using form builder
also change in code
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("1")
'If LoadLayout = ("1") Then
'Root.LoadLayout("2")
'Root.LoadLayout("3")
xui.SetDataFolder("TableAndForms")
editCol = B4XTable1.AddColumn("Edit", B4XTable1.COLUMN_TYPE_TEXT)
editCol.Sortable = True
editCol.Width = 127dip
B4XTable1.RowHeight = 50dip
B4XTable1.NumberOfFrozenColumns = 1
'// B4XTable1.AddColumn("Type", B4XTable1.COLUMN_TYPE_TEXT)
'// B4XTable1.AddColumn("Name", B4XTable1.COLUMN_TYPE_TEXT)
'// B4XTable1.AddColumn("Birth Date", B4XTable1.COLUMN_TYPE_DATE)
'// B4XTable1.AddColumn("Sex", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Mode", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Day", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Time", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Bell_Typ", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("M_No", B4XTable1.COLUMN_TYPE_TEXT)
LoadData
PrefDialog.Initialize(Root, "ADD Bell Time", 300dip, 300dip)
PrefDialog.LoadFromJson(File.ReadString(File.DirAssets, "template.json"))
'PrefDialog.SetOptions("Type", File.ReadList(File.DirAssets, "animals.txt"))
'PrefDialog.SearchTemplate.MaxNumberOfItemsToShow = 300
B4XTable1.MaximumRowsPerPage = 20
B4XTable1.BuildLayoutsCache(B4XTable1.MaximumRowsPerPage)
For i = 1 To editCol.CellsLayouts.Size - 1
Dim p As B4XView = editCol.CellsLayouts.Get(i)
p.AddView(CreateButton("btnEdit", Chr(0xF044)), 2dip, 5dip, 40dip, 40dip)
p.AddView(CreateButton("btnDelete", Chr(0xF00D)), 44dip, 5dip, 40dip, 40dip)
p.AddView(CreateButton("btnDuplicate",Chr(0xF0C5)), 85dip, 5dip, 40dip, 40dip)
Next
End Sub
Private Sub ShowDialog(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("Mode"), Item.Get("Day"), Item.Get("Time"), Item.Get("Bell_Typ"), Item.Get("Mp3_No"))) '// keys based on the template json file
If RowId = 0 Then 'new row
B4XTable1.sql1.ExecNonQuery2($"INSERT INTO data VALUES("", ?, ?, ?, ?, ?)"$, params)
B4XTable1.ClearDataView
Else
params.Add(RowId)
'first column is c0. We skip it as this is the "edit" column
B4XTable1.sql1.ExecNonQuery2("UPDATE data SET c1 = ?, c2 = ?, c3 = ?, c4 = ?, c5 = ? WHERE rowid = ?", params)
B4XTable1.Refresh
End If
End If
End Sub
but getting some error's
here attached images
i am working on b4a projects, its based on >> https://www.b4x.com/android/forum/threads/b4x-cross-platform-editable-b4xtable-form-example.104766/
i am try to add time-24 hour format, also update json file using form builder
also change in code
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("1")
'If LoadLayout = ("1") Then
'Root.LoadLayout("2")
'Root.LoadLayout("3")
xui.SetDataFolder("TableAndForms")
editCol = B4XTable1.AddColumn("Edit", B4XTable1.COLUMN_TYPE_TEXT)
editCol.Sortable = True
editCol.Width = 127dip
B4XTable1.RowHeight = 50dip
B4XTable1.NumberOfFrozenColumns = 1
'// B4XTable1.AddColumn("Type", B4XTable1.COLUMN_TYPE_TEXT)
'// B4XTable1.AddColumn("Name", B4XTable1.COLUMN_TYPE_TEXT)
'// B4XTable1.AddColumn("Birth Date", B4XTable1.COLUMN_TYPE_DATE)
'// B4XTable1.AddColumn("Sex", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Mode", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Day", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Time", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("Bell_Typ", B4XTable1.COLUMN_TYPE_TEXT)
B4XTable1.AddColumn("M_No", B4XTable1.COLUMN_TYPE_TEXT)
LoadData
PrefDialog.Initialize(Root, "ADD Bell Time", 300dip, 300dip)
PrefDialog.LoadFromJson(File.ReadString(File.DirAssets, "template.json"))
'PrefDialog.SetOptions("Type", File.ReadList(File.DirAssets, "animals.txt"))
'PrefDialog.SearchTemplate.MaxNumberOfItemsToShow = 300
B4XTable1.MaximumRowsPerPage = 20
B4XTable1.BuildLayoutsCache(B4XTable1.MaximumRowsPerPage)
For i = 1 To editCol.CellsLayouts.Size - 1
Dim p As B4XView = editCol.CellsLayouts.Get(i)
p.AddView(CreateButton("btnEdit", Chr(0xF044)), 2dip, 5dip, 40dip, 40dip)
p.AddView(CreateButton("btnDelete", Chr(0xF00D)), 44dip, 5dip, 40dip, 40dip)
p.AddView(CreateButton("btnDuplicate",Chr(0xF0C5)), 85dip, 5dip, 40dip, 40dip)
Next
End Sub
Private Sub ShowDialog(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("Mode"), Item.Get("Day"), Item.Get("Time"), Item.Get("Bell_Typ"), Item.Get("Mp3_No"))) '// keys based on the template json file
If RowId = 0 Then 'new row
B4XTable1.sql1.ExecNonQuery2($"INSERT INTO data VALUES("", ?, ?, ?, ?, ?)"$, params)
B4XTable1.ClearDataView
Else
params.Add(RowId)
'first column is c0. We skip it as this is the "edit" column
B4XTable1.sql1.ExecNonQuery2("UPDATE data SET c1 = ?, c2 = ?, c3 = ?, c4 = ?, c5 = ? WHERE rowid = ?", params)
B4XTable1.Refresh
End If
End If
End Sub
but getting some error's
here attached images
Attachments
Last edited: