How to fill an editor update form selection list dynamically based on other fields' selected value
How to fill an editor update form selection list dynamically based on other fields' selected value
Hi,
I have an editor update form that updates a record in a table and that has two fields with a selection list. The first field has a selection list that is queried from the database. Works fine. (field is of type 'select' and the c# initialisation code in the controller retrieves a list of values).
My question is, I want the values of the second list in the update form to be determined by the selected value in the first list. (The first list is a project list and the second list is an activity in the selected project.). So each time the user selects a value in the first list, the second list must be updated based on the selected value. How can this be done with datatable editor forms?
Thanks in advance,
Bert-Jan
Replies
Hi,
you could do something like this:
the load_list would be a ajax function where you get the items from the database for the project val
Cheers
Hannes
Actually - you can simplify that code -
dependent()
will make the Ajax call for you. You can configure it to use a local function as @btree has, but you might find it easier to just let it make the call for you.You will need to write an access API on the server that will accept the Ajax request and return the JSON with the options. The
dependent()
documentation has details of this.Allan
Thanks a lot! Got this to work by simply adding
And I had to code a GetActivities controller action that return json with an option object and values for the activity form select input control