the select list on left with 2 items (CB1, CB2) is dynamically generated.
the grid on right has dynamic repeat boxes with 2 items shown in each box from the database.
what we want to do is, on selection of CB1 from the list, the GRID on right side should filter with items which fall under CB1.
how do we set a dynamic action to run a query on selection of the one item from the list which will effect the view on the right side grid.
Hi @nshkrsh,
Thatâs easy to achieve using 2 server actions with a query in each of them.
Server action with a database query for the category (CB1, CB2) which you bind in the left column
Server action with a database query for the records in the grid. In this server action, create a GET variable under globals. Call it ⌠âfilterâ for example. Assign it as a value in the filters tab of the query builder.
On your page:
Add you server actions on the page (you need them to create the repeat regions)
Create a variable (insert > data > variable)
Use this variable value as a value for the get variable for your second server action (for the grid)
In the left column, select the repeated element > dynamic events > on click > set variable value and set the ID as a var value.
As soon as you click an element in the left column, the variable value changes and it filters the server action for the grid elements.
On the left column, there is no repeat element. It is a regular 'select' html element.
The click option needs to be set for each "option" item inside the 'select' element. But with the dynamic event click event, actual selection click event is not happenning.
So, if I click it two-three times, it eventually works, but that's of no use.
Also, there is no way to set the first item as selected for the 'select' element in UI.
The logic is the same as here Filtering Database Query with a Text Input but instead of using a text field you bind the select value for the filter and in the query builder you use âequalâ instead of âcontainsâ âŚ
Yes, the variable part I figured out. But the issue here is that on selecting an âoptionâ item inside the âselectâ element, the click event is not fired.
If I click the already selected option again, then the event is fired and data is generated.
This is because the event which I need to bind with is âselected/changeâ event and not the âclickâ event.
I tried using the âchangeâ event in dynamic attribute, but its broken too.
You donât need to apply any event on the select. Please remove any if added. You do not need the variable on the page as well.
Please check the link i sent you - it shows how to filter a query with a text field but it is the same except you are using a select and the condition should be âequalâ instead of âcontainsâ
In the selected value in the UI - select your server connect > data > query > binding which should generate an expression like: serverconnect1.data.query1[0].category which is the first value in the query.
If you remove the âsizeâ attribute from the select then the first record will be automatically selected.