How to Dynamically Change the Options of a Select Box or Radio Button - YouTube

Channel: unknown

[5]
Hey there! Welcome to Joget Tutorial series.
[9]
In this video, we're going to learn how to set up a dynamic cascading dropdown list.
[14]
This enables one to change the options or selections of a select box, radio button, or radio-based element on another form's field value.
[24]
Okay, let's begin!
[26]
First, log in using the administrator account.
[29]
The default admin user's username and password are both "admin".
[34]
Once you've logged in, click on Design New App.
[39]
Let's create a new app called "Dynamic Cascade Selectbox".
[43]
As a best practice, ensure the App ID is in camel case.
[46]
Once you've clicked on the Save button: you will be directed to the Design App page.
[53]
Before we begin, let's maximize the overlay by clicking on the green button on the top right corner.
[59]
Alright, in order to begin...
[61]
we will need to have 2 CRUDs.
[64]
The first CRUD is the Floor Form.
[66]
The form contains a single text field that defines the name of each floor level.
[71]
To learn how to build a CRUD, take a look at "How to create a CRUD via the App Generator" video.
[78]
The second CRUD determines how many rooms there are on certain floors.
[83]
It contains a text field for the name of the room and a selectbox that determines which floor it resides
[89]
The selectbox options are dynamic and are based on the first CRUD we created.
[94]
We'll need to use the Default Form Options Binder for that.
[98]
Take a look at "How to use Default Form Options Binder" video.
[102]
Pause the video here and try building the 2 CRUDS.
[106]
Once you're done, resume the video.
[109]
Alright, by now you have your 2 CRUDs up and running.
[112]
Ensure to add some data into the CRUD.
[116]
As you can see in my runtime, under "Manage Floors", I have 3 Floors
[124]
And in "Manage Rooms", I have added a few rooms on each floor.
[135]
Now we're all set to build the main form that contains the dynamic cascading dropdown list
[144]
Close the runtime tab and head back to the Design App
[147]
Click on Create New Form button.
[153]
We'll call this the "Booking Request Form".
[155]
Fill up the necessary details and click on Save.
[164]
Let's call this Section "Booking Request Details"
[172]
Click the OK button.
[174]
For the "Floor" selection, we'll use a radio button.
[181]
And for the "Room" selection, we'll use a selectbox.
[188]
Edit the Radio Button's properties
[193]
And we'll call this "Floor". Copy the ID as we'll use this later.
[203]
For Options Binder, select the "Default Form Options Binder".
[207]
Go to the Next page, and select "Floors" for the Form field.
[212]
In the Label Column Field, select "floor_name".
[216]
Click the OK button.
[221]
Edit the Select Box properties and set it as "Room".
[229]
For Options Binder, select the "Default Form Options Binder".
[233]
Go to the Next page and select "Rooms" for the Form field.
[239]
In the Label Column Field, select "room_name".
[243]
Now, this is important.
[245]
Set the Grouping Column to "floor"
[252]
Click on Next to open the Advanced Options.
[257]
Under the Dependency section, paste the ID of the radio button here.
[262]
This is important as this identifies that the "floor" ID that belongs to the radio button,
[266]
controls what options to be displayed for this "room" Select Box as we've grouped them by "floor" as shown in the previous configuration here.
[275]
Click the OK button.
[278]
Click on Preview to see how it'll look like in runtime.
[290]
Looks good. Alright, close the Preview tab and click on Save.
[298]
Let's generate a CRUD, go to runtime and try adding a new record.
[318]
Upon saving, the columns are showing the ID instead of the label.
[322]
We'll have to fix that.
[324]
Take a look at "How to use Default Form Options Binder" video on how to display the label instead of the Id for the columns.
[330]
Good Job. We are done with this tutorial. Thanks for watching!