jquery - dxDataGrid - 将列标题过滤器与 CustomStore 一起使用
问题描述
我使用 devexpress 和 headerFilter 选项在从下拉列表中选择一些选项并执行 OK 时出现问题:标头过滤器不会将所选值传递给 loadOptions 对象,如果我用 headerFilter 替换查找但我不想要查找它可以工作。
基本上我想调用另一个 api 来在 headerFilter 中加载数据
这是我的代码:
var store = new DevExpress.data.CustomStore({
key: "ID",
load: function (loadOptions) {// loadOptions does not contains the selected value
var d = $.Deferred(),
params = {};
[
"sort",
"filter"
].forEach(function(i) {
if(i in loadOptions && isNotEmpty(loadOptions[i]))
params[i] = JSON.stringify(loadOptions[i]);
});
$.getJSON(dataTable.replace("{numberOfRow}", loadOptions.take).replace("{page}", (loadOptions.skip / loadOptions.take) + 1), params)
.done(function (result) {
d.resolve(result.UserTasks, {
totalCount: result.Count
});
});
return d.promise();
}
});
opt = {
dataSource: store,
remoteOperations: { filtering: true, sorting: true, paging: true, grouping: false },
showBorders: true,
allowColumnReordering: true,
rowAlternationEnabled: true,
filterRow: {
visible: true,
applyFilter: "auto"
},
searchPanel: {
visible: true,
width: 240,
placeholder: "Search..."
},
headerFilter: {
visible: true
},
paging: {
pageSize: 10
},
pager: {
showPageSizeSelector: true,
allowedPageSizes: [10, 20, 30],
showInfo: true
},
columns: [{
dataField: "Title",
dataType: "string",
caption:idea,
width:180,
//allowFiltering: false,
//allowSearch: true,
cellTemplate: function (element, info) {
url = url.replace("/Ideas/View", "/Ideas");
element.append("<a class='view-task' href=" + url + "/" + info.data.ID + " data-task-id=" + info.data.ID + ">" + info.data.Title + '-' + ideano + info.data.IdeaId + "</a>");
}
},
{
dataField: "FormName",
caption: form,
dataType: "string",
headerFilter: { //here its bringing all data properly
dataSource:{
store: new DevExpress.data.CustomStore({
key: "Id",
load: function (loadOptions,i) {
var d = $.Deferred(),
params = {};
[
"sort",
"filter"
].forEach(function (i) {
if (i in loadOptions && isNotEmpty(loadOptions[i]))
params[i] = JSON.stringify(loadOptions[i]);
});
$.getJSON(filterDataTable.replace("{filter}", form).replace("{numberOfRow}", loadOptions.take).replace("{page}", (loadOptions.skip / loadOptions.take) + 1), params)
.done(function (result) {
d.resolve(result.Items);
});
return d.promise();
}
})
}
}
}]
}
$("#gridContainer").dxDataGrid(opt).dxDataGrid("getDataSource");
解决方案
推荐阅读
- c# - 使用通用方法提取枚举标志以列出?
- angular - 有没有机会在角度 ng2-fan-menu 中更改图标(从本地路径 img)
- macos - 如何在 macOS 上显示正在运行的进程列表?
- ruby-on-rails - 如何在 rails-postgres 中存储每个用户提交的表单?
- javascript - Timeline Vis - 使用子组排序强制子组 2 在子组 1 之后
- checkbox - Rails 编辑表单复选框不检查布尔真值
- python - 使 Tkinter 框架填充垂直轴
- dji-sdk - “stopAircraftFollowing”方法不提供回调
- java - 微服务中的外部 URL 配置
- javascript - 访问 html 页面上的缓存?