Ola
Download BANanoWebix Things
The project source code is on the BANanoWebixMultiPage folder. Ensure to update the external libraries folder for b4j with contents of the 1. Libraries folder.
Part 3 of our lesson looked at the addition of the grid and forms for both cities and positions of our app. In Part 4, we will look at adding more functionality to our app.
1. For grids, detect 'delete' and 'insert' key press and perform relevant functions.
2. For deletes, show a confirm dialog and process a delete once Yes is selected. This removes the record from the db and refreshes the data-table.
3. Hiding & Showing elements of the page depending on what is being actioned.
4. CRUD functionality for both 'add' and 'edit' modes.
5. Data-table double click to activate 'edit' mode.
6. Adding toolbar to a form - to house crud related buttons
7. Using spacers to make our forms proper for displays.
We want when the cities / positions pages are selected on the side bar, the relevant selected page should show, the existing records for either should show and the form for CRUD functionality should be shown.
As we are continuing from Part 3, we have just added more functions to ensure that both screens work as expected.
Positions / Cities
When this page is selected, we link the Page objects with .SetPage(?), on the respective modules this stores a global variable called Page and opens the BANanoSQL database.
After that the existing records are loaded with LoadPositions / LoadCities
We want to ensure that the details of the forms are cleared and only the needed buttons are shown, case in point 'bntNew...'
These buttons are sitting in the toolbars at the bottom of the page. To separate the form and the toolbar at the bottom we used a 'spacer'
All the code that is related to maintaining Cities in happening in the modCities module and all the code to manage the positions is happening in the modPositions modules. It is better this way as managing and maintaining the code is easier.
In Part 3, we only added form elements to our forms and did not include the toolbar, so in the CreateForm?? method, we first start by adding a spacer and then the toolbar with the needed icons.
As noted above, some of these icons are hidden. To ensure that they are not very close to each other we set the width of each button to be 100. We also assign events to them for adding, cancelling, saving, deleting etc.
We also added required on the form elements and added some validation because the contents are compulsory.
For example...
Download BANanoWebix Things
The project source code is on the BANanoWebixMultiPage folder. Ensure to update the external libraries folder for b4j with contents of the 1. Libraries folder.
Part 3 of our lesson looked at the addition of the grid and forms for both cities and positions of our app. In Part 4, we will look at adding more functionality to our app.
1. For grids, detect 'delete' and 'insert' key press and perform relevant functions.
2. For deletes, show a confirm dialog and process a delete once Yes is selected. This removes the record from the db and refreshes the data-table.
3. Hiding & Showing elements of the page depending on what is being actioned.
4. CRUD functionality for both 'add' and 'edit' modes.
5. Data-table double click to activate 'edit' mode.
6. Adding toolbar to a form - to house crud related buttons
7. Using spacers to make our forms proper for displays.
We want when the cities / positions pages are selected on the side bar, the relevant selected page should show, the existing records for either should show and the form for CRUD functionality should be shown.
As we are continuing from Part 3, we have just added more functions to ensure that both screens work as expected.
B4X:
'controller code for the side menu
Sub SettingsHandler(pg As WixPage, menuitem As String)
ourclients.OpenWait("ourclients", "ourclients")
Page = pg
Select Case menuitem
Case "settings_positions"
pg.Show("mv_settings_positions")
modPositions.SetPage(Page)
modPositions.LoadPositions
Page.Clear("formpositions")
Page.ClearValidation("formpositions")
Page.Show("btnnewposition")
Page.HideMulti(Array("btncancelposition","btnsaveposition","btndeleteposition"))
Case "settings_cities"
pg.Show("mv_settings_cities")
modCities.SetPage(Page)
modCities.LoadCities
Page.Clear("formcities")
Page.ClearValidation("formcities")
Page.Show("btnnewcity")
Page.HideMulti(Array("btncancelcity","btnsavecity","btndeletecity"))
End Select
End Sub
Positions / Cities
When this page is selected, we link the Page objects with .SetPage(?), on the respective modules this stores a global variable called Page and opens the BANanoSQL database.
After that the existing records are loaded with LoadPositions / LoadCities
We want to ensure that the details of the forms are cleared and only the needed buttons are shown, case in point 'bntNew...'
These buttons are sitting in the toolbars at the bottom of the page. To separate the form and the toolbar at the bottom we used a 'spacer'
All the code that is related to maintaining Cities in happening in the modCities module and all the code to manage the positions is happening in the modPositions modules. It is better this way as managing and maintaining the code is easier.
In Part 3, we only added form elements to our forms and did not include the toolbar, so in the CreateForm?? method, we first start by adding a spacer and then the toolbar with the needed icons.
B4X:
form.AddRowsSpacer("")
'
Dim toolbar1 As WixToolBar
toolbar1.Initialize("tlbpos")
Dim btnBack As WixIcon
btnBack.Initialize("btnback")
btnBack.SetIcon("mdi mdi-keyboard-backspace")
btnBack.SetTooltip("Go back")
btnBack.SetWidth("100")
btnBack.SetClick(BANano.CallBack(Me,"btnback_click",Null))
toolbar1.AddIcon(btnBack)
toolbar1.AddSpacer
Dim btnnewposition As WixIcon
btnnewposition.Initialize("btnnewposition")
btnnewposition.SetIcon("mdi mdi-plus")
btnnewposition.SetTooltip("Add a new position")
btnnewposition.SetWidth("100")
btnnewposition.SetClick(BANano.CallBack(Me,"btnnewposition_click",Null))
toolbar1.AddIcon(btnnewposition)
Dim btncancelposition As WixIcon
btncancelposition.Initialize("btncancelposition")
btncancelposition.SetIcon("mdi mdi-cancel")
btncancelposition.SetTooltip("Cancel new position")
btncancelposition.SetWidth("100")
btncancelposition.SetClick(BANano.CallBack(Me,"btncancelposition_click",Null))
btncancelposition.SetHidden(True)
toolbar1.AddIcon(btncancelposition)
Dim btnsaveposition As WixIcon
btnsaveposition.Initialize("btnsaveposition")
btnsaveposition.SetIcon("mdi mdi-content-save")
btnsaveposition.SetTooltip("Save the position")
btnsaveposition.SetWidth("100")
btnsaveposition.SetClick(BANano.CallBack(Me,"btnsaveposition_click",Null))
btnsaveposition.SetHidden(True)
toolbar1.AddIcon(btnsaveposition)
Dim btndeleteposition As WixIcon
btndeleteposition.Initialize("btndeleteposition")
btndeleteposition.SetIcon("mdi mdi-trash-can")
btndeleteposition.SetTooltip("Delete position")
btndeleteposition.SetWidth("100")
btndeleteposition.SetClick(BANano.CallBack(Me,"btndeleteposition_click",Null))
btndeleteposition.SetHidden(True)
toolbar1.AddIcon(btndeleteposition)
form.AddRows(toolbar1.Item)
As noted above, some of these icons are hidden. To ensure that they are not very close to each other we set the width of each button to be 100. We also assign events to them for adding, cancelling, saving, deleting etc.
We also added required on the form elements and added some validation because the contents are compulsory.
For example...
B4X:
value.SetRequired(True)
value.SetValidateIsNotEmpty(True)
value.SetInvalidMessage("The position should be specified")
Last edited: