Closed dhiraj closed 8 years ago
Hi,
It is pretty straightforward, it is just specifying what field triggers the filtering ("filterTriggers": ["items.CountryID"]
) and what condition to apply ("filter" : "items.CountryID==item.CountryID"
).
I would recommend looking at the example: https://github.com/OptimalBPM/angular-schema-form-dynamic-select/blob/master/app.js#L186
Also, the help section on the filtering is helpful(although I just saw an error there, "items" should be "titleMap"): https://github.com/OptimalBPM/angular-schema-form-dynamic-select#filters
Oh, I saw that your model is called "item", thought it was "items". That is a problem, as that conflicts with the local "item"-variable in the condition. I would advice you to rename the model to "model" or something else. This is not just for the sake of ASDFS, but because the name "item" doesn't say much about it and that it is usually what it is called in the ASF-documentation. (If in doubt, do as everyone else)
It looks like changing the model name seems to have helped! :)
I'm looking deeper, but I was able to get Country->State filtering working, thanks!
I've got it mostly working, but there is a problem with 3rd (and further levels) of nested ASFDS controls.
In the same Country->State->City scenario, I've got all 3 working in the normal case using ==
matching on IDs.
Problem: Suppose the user sets Country
, State
and City
once. Then, when Country
is set again, State
should get filtered by Country
and become unset; this happens, and then City
should get filtered by State == undefined
(this does not happen). City
continues to show the value selected within the State
from the earlier State
setting, before the user set the Country
.
This can lead to an incorrect value being submit to the backend Server, when like in my case only City
is submit and the Country
and State
values are discarded.
Thoughts?
I don't know why City
doesn't react when State
is being unset. I can't debug your application, but a breakpoint in the select filter should be able to let you find out where the problem arises:
https://github.com/OptimalBPM/angular-schema-form-dynamic-select/blob/master/src/angular-schema-form-dynamic-select.js#L367
Have you gotten anywhere with this?
No, I couldn't put more time on this, until now. I will probably revisit this after about 3 weeks, will update. In the meantime, you can close this issue right now.
I want to set up a chain of ASFDS drop downs and I'm not being able to figure out how to wire it up, all together.
My model on the
$scope
is calleditem
. I've got an ASF form with ASFDS drop downs, the idea is that we will have chaining drop downs - when one is selected the next one will filter to match.Take for example, this schema
and this form:
When the user changes
country
,state
should be filtered. When the user changesstate
,city
should be filtered. I've got all three ASFDSs showing all values, with asyncCallback fetches, all that works well. Problem is, how to do a change cascade filter?I tried using the filter clauses, but could not get it to work. If you could provide more examples, of how to do this, or more details on the filter clauses, I would really appreciate it and make it work.
Thanks!