In this video, you will learn how to add or remove table entries in your Centrldesk application.
In this example, we will show you how to provide functions behind buttons and how your application interacts with the database. So let's start building our application:
Steps:
- We have already created a table with three columns and we have also already createt a database table with sample data.
- First we go to the page editor by clicking on the Edit Page button in the upper right menu.
- The Page Editor opens.
- Drag and drop a button element under general to the middle of the page editor.
- Select the button.
- Change the Style to "Raised".
- Change the Text to "Add entry".
- Change the icon.
- In this example we choose a "plus" icon.
- Change the color to green.
- Drag and drop a button element under general to the middle of the page editor.
- Select the button.
- Change the Style to "Raised".
- Change the Text to "Remove selected entry".
- Change the icon.
- In this example we choose a "cross" icon.
- Change the color to red.
- Select the "Add entry" button.
- On the right side, under Actions, click Add on click.
- The flow editor opens.
- Drag and drop the page element under App Components to the middle of the flow editor.
- The Use page dialog opens.
- Select New Page.
- Enter a name.
- In this example we enter "Add new Employee".
- At "Bind data to page" we select the Employees table of our database.
- Confirm with ok.
- Because we want to show our new page as a dialog later, we add our page as "Show Dialog" and remove the "Navigate" block.
- In Centrldesk you always have the option of displaying pages as entire pages or as dialogs.
- Select the "Show Dialog Add new Employee" block.
- Click on Edit Page.
- The Page Editor opens.
- Add a Text Input to the page.
- Select the text input.
- Change the Label to "First Name".
- Change the "Object Property Binding" to the corresponding table entry.
- Add a Text Input to the page.
- Select the text input.
- Change the Label to "Last Name".
- Change the "Object Property Binding" to the corresponding table entry.
- Add a Text Input to the page.
- Select the text input.
- Change the Label to "Position".
- Change the "Object Property Binding" to the corresponding table entry.
- Add a Button to the page.
- Change the text to "Add entry".
- Change the icon.
- In this example we choose a "plus" icon.
- Change the color to green.
- On the right side, under Actions, click Add on click.
- The Flow editor opens.
- Drag and drop the Database element under App Components to the middle of the flow editor.
- Select Save row of Employees.
- Confirm with ok.
- Drag and drop the Page Control element under Scope to the middle of the flow editor.
- Select Submit Dialog.
- Confirm with ok.
- Connect the output of the save row of employees block to the input of the submit dialog block.
- Select the save row of employees block.
- On the right side, select custom under row to save.
- The Logic editor opens.
- Drag and drop the first name element under Scope to the middle of the Logic editor.
- Drag and drop the last name element under Scope to the middle of the Logic editor.
- Drag and drop the position name element under Scope to the middle of the Logic editor.
- Drag and drop the Workspace Object element under Libraries to the middle of the Logic editor.
- The Workspace object dialog opens.
- Select Create Employee.
- Confirm with ok.
- Drag and drop the Data Row element under Libraries to the middle of the Logic editor.
- The Data Row dialog opens.
- Select Create Data Row.
- Confirm with ok.
- Select Data Row als Data Row Type.
- Select Employees als table.
- Confirm with ok.
- Now the outputs of the blocks must be connected to the corresponding inputs of the blocks.
- The preview values help the user to connect the database values to the table columns.
- Close the Logic editor by clicking close in the upper right corner.
- Close the Flow editor by clicking close in the upper right corner.
- Close the Page Editor by clicking close in the upper left corner.
- Drag and drop the Page Control element under Scope to the middle of the flow editor.
- Select Refresh Table.
- Confirm with ok.
- Connect the submit output of the Show Dialog Add new Employee block to the input of the Refresh table block.
- Select the Refresh Table block.
- On the right side, select the table to refresh.
- Close the Flow editor by clicking close in the upper right corner.
- Close the Page Editor by clicking close in the upper left corner.
- Now we can start using our application.
- Click Add Entry.
- Our dialog with the required inputs is displayed.
- Enter values for First Name, Last Name, and Position.
- Click on the Add Entry.
- Our new entry has been successfully written to the database table and our view in the user interface has updated.
- Now we are able to store values.
- Next we need a remove function.
- Go to the page editor by clicking on the Edit Page button in the upper right menu.
- The Page Editor opens.
- Select the "Remove selected entry" button.
- On the right side, under Actions, click Add on click.
- The flow editor opens.
- Drag and drop the Interaction element under Libraries to the middle of the flow editor.
- The Interaction dialog opens.
- Select Confirm.
- Confirm with ok.
- On the right side under header select "Enter Value".
- Enter "Confirmation required" as value.
- On the right side under message select "Enter Value".
- As value enter "Remove selected row?".
- Confirm dialogs are very useful, for example to add a short confirmation prompt to delete functions.
- Drag and drop the Database element under App Components to the middle of the flow editor.
- The Use Database dialog opens.
- Select Delete row of Employees.
- Confirm with ok.
- Connect the output of the confirm block to the input of the Delete row of employees block.
- Select the Delete Row of Employees block.
- On the right side under Row to delete select "Custom".
- The Logic Editor opens.
- Drag and drop the table element under scope in the middle of the logic editor.
- Connect the get selection output of the table block to the input of the row to delete block.
- Close the Logic editor by clicking close in the upper right corner.
- Drag and drop the Page control element under Scope to the middle of the flow editor.
- The Page Control dialog opens.
- Select Refresh table.
- Confirm with ok.
- Connect the output of the delete row of employees block to the input of the Refresh table block.
- Select the Refresh Table block.
- On the right side, select the table to refresh.
- Close the Flow editor by clicking close in the upper right corner.
- Close the Page Editor by clicking close in the upper left corner.
- Now we can start using our application.
- Select a row whose entry you want to delete.
- Click Remvoe selected Entry.
- Our confirm dialog is displayed.
- Confirm the dialog by clicking OK.
- The entry was successfully deleted from the database. The table of our graphical user interface has updated and shows the correct data.