Editor form column filtering
Editor form column filtering

in DataTables 2
How can I accomplish the following?
My Editor form has two (or more) fields, both pulldowns (using Selectize). Since the field arrays are loaded at startup, I cannot implement it via SQL in the PHP file.
Depending on the option that the user selects in pulldown A, I want to filter (based on a FK) the entries shown for pulldown B.
Thanks!
This question has accepted answers - jump to:
Answers
See if this thread helps you get started.
Kevin
Hi Kevin,
Most definitely! And I've used
dependent
before, just couldn't remember.How, though, would I filter the array/json for the second pulldown, using the key/value entered in the first pulldown?
filter()
should work.On second thought (after tracing through the code in DevTools), since the JSON for pulldown B is already loaded at that point, it seems that I need to use
ajax
in thedependent
call.Yes, you could do that if you want to get the filtered data from the server. If Selectize offers a way to filter already loaded options, that might work, but I don't immediately recall such an option.
Allan
Allan,
I added the following, which is returning the correct values.
How can I connect it to the field, which currently looks like this?
Using
field().update()
in yoursuccess
callback would be the way to update the options that Selectize has.Allan
Allan,
Thank you; works great!
One remaining issue. In the code:
On the line with the success function, the parameter 'json' is not refreshed. I placed a breakpoint and the code is executed and the value of discount_id is changed, but json retains its value from the first/previous call; therefore, there is nothing new to filter.
How do I force a refresh?
Use the browser's network inspector to see what the response JSON is. It sounds like the server might be returning the same JSON each time.
Kevin
Never mind! I had a bad field.