我想添加一個項目到kendoDropDownList,它似乎添加了選項,但沒有設置值和文本。檢查選擇它只是增加了一個新的選擇添加項目kendoDropDownList
<option></option>
這裏是我使用
$("#nameList").data("kendoDropDownList")
.dataSource.add({ "text": "Joe", "value": "Joe" });
UPDATE
這是我的數據源模型和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;
}
}
});
Then Then Later
$("#people_list").kendoDropDownList({
dataTextField: "text",
dataValueField: "value",
dataSource: {
datasource_people,
requestEnd: function (e) {
e.response.push({text: "John", value: "John"});
}
}
});
其工作就像魅力!謝謝Hector。 – vel