简体   繁体   中英

Populate Kendo DropDownList with array from selected value

Using javascript I want to populate a dropdownlist (DDL2) with certain data from a REST JSON endpoint based on the selected value of the DDL2.

This DDL2 selected value is triggered by previous DDL1 selection (I have that part working). For example if DDL1 selected value is "Town" then the selected value for DDL2 is: "SELECT towninfo FROM towns ORDER BY towninfo". It's a SQL query, currently. I have the option of replacing it with a comma-delimited array of towns (RALEIGH,CHARLOTTE,ASHEVILLE...), or I could replace it with a JSON string. I'm open for suggestions on that part.

What I want to do is populate DDL2 with the selected array. So when I select "Towns" in DDL1 then DDL2 populates with a list of towns. Thanks!

If you mean something simple as populating a second drop down based on the first one's selection, here is a quick and dirty sample...

http://jsbin.com/AHOpAJA/1/edit

If you want something a bit more complicated, here is another one using three dropdowns, that all bind from a service. http://jsbin.com/ihodoc/3/edit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM