ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
AjaxDropDowns Cascading with multiple parents
Title:
B
I
{code}
?
Hello, I have different controls AjaxDropDown cascading multiple and dependent parents : 1. @Html.Awe().AjaxDropdownFor(m => m.MakeId) 2. @Html.Awe().AjaxDropdownFor(m => m.ModelId).Parent (m => m.MakeId, "makeId") 3. @Html.Awe().AjaxDropdownFor(m => m.FuelTypeId).Parent (m => m.ModelId, "modelid").Parent(m => m.MakeId, "makeId") 4. @Html.Awe().AjaxDropdownFor(m => m.BodyTypeId).Parent(m => m.FuelTypeId , "fuelTypeId").Parent(m => m.ModelId, "modelid").Parent (m => m.MakeId, "makeId") The first three are working properly but the latter is not loading properly because the controller action that receives events from each of the parents does not always execute in the desired order . For example, when I change the value in the second AjaxDropDown(2º), the controller action that load the last AjaxDropDown(4º) runs twice. Once with the current AjaxDropDown(3º) parameter and the other with a different parameter which is the result of its new value in AjaxDropDown(3º). The controller action with the correct parameters runs before the same action with the wrong parameters. I have also tried: @Html.Awe().AjaxDropdownFor(m => m.BodyTypeId).Parent (m => m.FuelTypeId , "fuelTypeId").Parameter("modelid", Model.ModelId). Parameter("makeId" Model.MakeId) But in this case after any parent AjaxDropDown is loaded no longer send the parameter. Could I do something to solve this issue? Thanks in advance.
Save Changes
Cancel
Albert
asked at 17 Mar 2014
Answers
B
I
{code}
?
the component should not be the child of it's parent and grandparent, on parent change the child is getting reloaded with the new value of the parent, in your case the grandparent triggers the parent and the grandchild plus the parent triggers the child again, that's why this is a bad idea. since you have the value of the parent you can figure out the value of the grandparent so you don't need to bind it as a parent e.g. if you know that country is France you know that continent Europe
Save Changes
Cancel
Omu
answered at 17 Mar 2014
Thank you very much for the quick reply. If the data structure was like "tree", then I would do as you told me. In fact with the make and model I can simplify as you mention, but for example, if a car is gasoline fuel type, I can not know what make and model belongs to. Therefore I need to pass as a parameter the parent and the grandparent. Thank you again.
at 17 Mar 2014
Albert
when you calculate the list of available FuelType you need to parent both modelId and makeId, you can't figure out the makeId by having the modelId ?
at 17 Mar 2014
Omu
I can figure out FuelTypeId with ModelId, but I can not figure out BodyTypeId just with FuelTypeId. I need at least the FuelTypeId and ModelId
at 17 Mar 2014
Albert
think you can incorporate the value of the modelid in the fuel dropdown so for the values on the fuel dropdown instead of just {1, 2, 3} you would have {1|model1, 2|model1, 3|model1}, this way the BodyTypeId dropdown will have to parent only the fuelTypeId dropdown
at 17 Mar 2014
Omu
Ok, I will try. Thanks!
at 17 Mar 2014
Albert
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK