[英]kendodropdownlist filter json response that has field
我目前正在做以下工作; 我所有的 JSON 條目都有styleName
,但是有些條目有字段txt
,我只想顯示下拉列表中包含txt
字段的styleName
數據。
var dataSourceJSON = new kendo.data.DataSource({
transport: {
read: {
url: dataURL,
dataType: "json",
type: 'GET'
}
}});dataSourceJSON.read();
$("#dropdown").kendoDropDownList({
dataSource : dataSourceJSON,
dataTextField : "styleName"
});
使用劍道之前,我是用下面實現這個,內fetch
經典的下拉列表。 但我不確定如何將這種邏輯與kendoDropDownList
if (data[i].txt) {
option.text = data[i].styleName;
dropdown.add(option);
}..../
更新,這是我目前所在的位置; 我可以在我的模式解析中console.log
正確的數據,但仍然很難將過濾后的數據放入下拉列表中。
var ctemp;
var dataSourceJSON = new kendo.data.DataSource({
transport: {
read: {
url: dataURL,
dataType: "json",
type: 'GET'
}
},
schema: {
parse: function(datC) {
console.log(datC);
for (let i = 0; i < datC.length; i++) {
if (datC[i].txt) {
ctemp = datC; // <-- This works and what I need
console.log(ctemp);
}
}
}
}
});dataSourceJSON.read();
$("#dropdown").kendoDropDownList({
optionLabel: "Choose",
dataSource : dataSourceC,
dataTextField : ctemp // <--- does nothing
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.