Load Dropdown based on row
Load Dropdown based on row
Hello Allan
Absolutely stuck at this point. Your help will be truly appreciated.
We have a requirement whereby, we click on the row to edit it, which brings up edit modal... all gr8.
So, in our edit form we have multiple fields. One of them is a dropdown, used for "STATUS"
Till now we were filling in the dropdown with one set of values. However, now we need to show different values / text based on the row selected.
For eg: If you select row 1: the user can only set the status to "delivered", "Cancel delivery"
but when you select row 2: the user can only set the status to "reorder order", "Cancel subscription", "delivered", "Cancel delivery"
So, basically We want to supply different "inOpts" to the editor based on the row clicked.
Currently the code i am using is
editobj = {
"label": lbl + ":",
"fieldInfo": "" + lblinfo + "",
"name": "" + lblname + "",
"dataProp": localnumdata[i],
"ipOpts": {}
"type": "select"
}
Answers
Hi,
This sounds like a perfect use case for the
dependent()
method. With that you can apply a condition to a field and specify the options you want the second field to have when the parent changes.Allan
so, dependent would be fine if we were updating a choice (like radio) in the editor panel.
However, I am looking to fill the dropdownlist in the editor using ipOpts, depending on a column value of the editing row. On editor load.
Allan pls provide me a code snippet to understand.
Thank you.
It still sounds like
dependent()
would be ideal, be it for radio inputs for select inputs (in fact, it makes no difference which of those two fields types are being used, the code would be identical).Alternatively, if you don't want to use
dependent()
, you could use theselect
field type'supdate()
method -editor.field( 'myField' ).update( ...options... );
whenever you want to set the value of the options.Allan
Please can you elaborate the syntax
editor.field( 'myField' ).update( ...options... );
There is an example in the
select
documentation. To explain it further, themyField
is the field name for the field you want to modify (just as you can doeditor.field('myField').val()
to get the field's value). The...options...
is your list of options - probably an array of objects.For example:
Allan