What is the recommendation for having the cascading combo take affect when the first combo has a selected item when it is loaded? This doesn't appear to trigger the selectionchanged event recommended in the example. Is there a bug here that the event is not triggered when the control loads and applies the selectedItem?
http://www.igniteui.com/combo/cascading-combos
Hello,
Thank you for contacting us!
About your question, could you please be more clear. As I understand you want then the combo is loaded, with selected item, automatically the second combo to be filled with data according to first combo value.
As you will notice the combos are filled with data on selectionChanged client event.
Yes so if the screen loads and the user selects UPS for example from a Carrier dropdown the selectionChanged event fires and the Service dropdown then filters. It does not work however if the screen loads and the combo binds to the view model using the selectedItems property to default the selection of the combo when the page loads. That default selection does not trigger the selectionChanged event so the filter of the 2nd combo does not happen. Is that a bug? How should cascading combos be handled when the page loads with a default bound value?
Hello Tammy,
You could use the itemsRendered event which would fire after the control is created with the specified initial selection. However, it is important to note that this event may fire before the other combos have been instantiated and could cause issues if placed on the initial combo. A workaround for this and the lack of other events is to handle the itemsRendered event on your final combo, as at this point you will know that all of the previous controls have been instantiated. I've placed the code for this in a modified version of the jsFiddle of the sample browser sample. I have also attached a copy of the sample with this update in case you would prefer to download it.
I understand that this is not an ideal solution and the team is currently in discussion about how this can be handled without requiring a workaround like this.
If you have any questions or concerns about this approach please let me know.
This is closer but rebinding the child combo causes itemsRendered to be called over and over again. I added an alert in your fiddle. Select a state and you will see it.
I will just stick an attribute on the combo so I know its already rendered.
As an FYI I ended up having to use the dropdownOpening event to evaluate this. We are using knockout binding and for some reason with the other event the dropdown was getting filled incorrectly.
Thank you for sharing the solution that you found. I am glad to hear that you were able to find a solution that works for you at this time.
Please let me know if I may be of any additional help.
I am good right now other than hoping you'll build this into a future release :)