我在过滤多选数据后遇到接收正确值的问题。
<script>
$(function () {
var productsDataSource = new kendo.data.DataSource({
type: "json",
serverFiltering: true,
transport: {
read: {
url: "/api/incident/issue",
},
parameterMap: function (data) {
return kendo.data.transports.odata.parameterMap.call(this, data);
}
}
});
$("#products").kendoMultiSelect({
autoBind: false,
dataTextField: "IssueName",
dataValueField: "IssueID",
dataSource: productsDataSource
});
$("#suppliers").kendoMultiSelect({
autoBind: false,
dataTextField: "CategoryName",
dataValueField: "CategoryID",
dataSource: {
type: "json",
serverFiltering: true,
transport: {
read: {
url: "/api/incident/category"
}
}
},
change: function () {
var filters = buildFilters(this.dataItems());
productsDataSource.filter(filters);
}
});
function buildFilters(dataItems) {
var filters = [],
length = dataItems.length,
idx = 0, dataItem;
for (; idx < length; idx++) {
dataItem = dataItems[idx];
filters.push({
field: "CategoryID",
operator: "eq",
value: parseInt(dataItem.CategoryID)
});
}
return {
logic: "or",
filters: filters
};
}
});
</script>
看来我在这一部分有一个问题
filters.push({
field: "CategoryID",
operator: "eq",
value: parseInt(dataItem.CategoryID)
});
operator: "eg",
我可以看到帖子没有这样的问题:
/api/incident/issue?%24inlinecount=allpages&%24format=json&%24filter=CategoryID%20eq%201
接收数据但没有正确过滤,请使用JSON运算符(等效)的任何帮助吗?
答案 0 :(得分:0)
解决。将serverfiltering:
的值从true,
更改为false,
。