且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将json正确绑定到Kendo DropDownList

更新时间:2022-05-30 02:48:04

也许您的JSON对于DropDownList而言不是最方​​便,但您可以将其绑定到KendoDropDownList而无需更改.

Maybe your JSON is not the most convenient for a DropDownList but you can bind it to a KendoDropDownList with no change.

将DropDownList定义为:

Define the DropDownList as:

$("#dropdown").kendoDropDownList({
    dataSource    : dataSourceTowns,
    dataTextField : "attributes.TNONAM"
});

请记住,dataTextField不一定非要是一个字段,可以是该字段的路径.

Remember that dataTextField doesn't strictly have to be a field, might be path to the field.

HTML所在的位置:

Where your HTML is:

<select id="dropdown"></select>