【发布时间】:2015-07-23 21:50:33
【问题描述】:
我正在尝试向 kendoDropDownList 添加一个项目,它似乎添加了选项但没有设置值和文本。检查选择它只是添加了一个新选项
<option></option>
这是我正在使用的
$("#nameList").data("kendoDropDownList")
.dataSource.add({ "text": "Joe", "value": "Joe" });
更新
这是我的数据源模型和建议的requestEnd,但值似乎搞砸了
datasource_people = new kendo.data.DataSource({
type: "json",
serverFiltering: true,
transport: {
read: {
dataType: 'json',
type: 'GET',
url: '/restful/people/'
}
},
filter: {
field: "status",
operator: "eq",
value: 1
},
schema: {
data: function(response) {
return response.data.plaintiffs;
},
model: {
id: "person_id",
fields: {
person_id: {type: "number"},
name: { type: "string"}
}
},
errors: "error",
total: function(response) {
return response.data.total;
}
}
});
后来
$("#people_list").kendoDropDownList({
dataTextField: "text",
dataValueField: "value",
dataSource: {
datasource_people,
requestEnd: function (e) {
e.response.push({text: "John", value: "John"});
}
}
});
【问题讨论】:
标签: javascript jquery kendo-ui kendo-dropdown