This is a migrated thread and some comments may be shown as answers.

Custom syncing of several DDLs

4 Answers 60 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Cristian
Top achievements
Rank 1
Cristian asked on 12 May 2015, 11:04 PM

So, I am using UI for ASP.NET MVC Q1 2015. I have 3 DDLs, configured to populate their data remotely(from action method inside a controller) using DataSource/Read action AJAX pattern.

I have some custom business logic I need to implement: when something gets changed in the 1st DDL, I have to do some custom calculations that may potentially involve what it has been selected in 2nd DDL so I can eventually change the selected values in the 3rd DDL.
So this here has nothing to do with datasource filtering or custom cascading.

My issue/concern here is: how can I do any such calculations/alterations of the other DDLs from inside a 'Changed' event handler in the 1st one safely, given all 3 are populated asynchronously? I mean, how can I be sure that when inside the Changed event handler in 1st DDL, data for 2nd & 3rd DDL had been fully loaded so I can use them in calculations and/or change the Selected value for those DDLs?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 14 May 2015, 08:53 AM

Hello Cristian,

The DropDownList will fire its dataBound event, when the data from the remote service is ready. So in your case you can listen for that dataBound event in order to be sure that the data is loaded. Here is the documentation about it:

http://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist#events-dataBound

Regards,
Kiril Nikolov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Cristian
Top achievements
Rank 1
answered on 15 May 2015, 12:34 AM

Thanks Kiril for your answer.  Not sure if I explained my scenario well enough, because I was well aware about dataBound event. But would not that mean I have to handle this event for DDL 2 & 3, change some global flags for this and then, somehow use them when handling the Change event for DDL 1? And what if data is not ready in DDL 2 and 3 to query for selections made there yet, means I would have to implement some sort of polling logic in in Change event for DDL 1.

All this sounds awfully tedious. Is there really no other way?

0
Cristian
Top achievements
Rank 1
answered on 15 May 2015, 12:35 AM

Thanks Kiril for your answer.  Not sure if I explained my scenario well enough, because I was well aware about dataBound event. But would not that mean I have to handle this event for DDL 2 & 3, change some global flags for this and then, somehow use them when handling the Change event for DDL 1? And what if data is not ready in DDL 2 and 3 to query for selections made there yet, means I would have to implement some sort of polling logic in in Change event for DDL 1.

All this sounds awfully tedious. Is there really no other way?

0
Kiril Nikolov
Telerik team
answered on 15 May 2015, 07:22 AM

Hello Cristian,

The dataBound event is the only way to get notified when the data is loaded, so there is no other way to achieve what you are looking for.

Regards,
Kiril Nikolov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DropDownList
Asked by
Cristian
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Cristian
Top achievements
Rank 1
Share this question
or