最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - KendoUI Grid alter filter and sort in one refresh - Stack Overflow

programmeradmin1浏览0评论

I am trying to set the filter and sort parameters and update my grid in one go instead of two separate calls such as:

grid.dataSource.filter({
    field: 'branchId',
    operator: 'eq',
    value: selectedBranchId
});
grid.dataSource.sort({
    field: 'id',
    dir: 'desc'
});

I have tried:

grid.dataSource.data({
    filter: {
      field: 'branchId',
      operator: 'eq',
      value: selectedBranchId
    },
    sort: {
      field: 'id',
      dir: 'desc'
    }
})
  grid.dataSource.read(); 
  grid.refresh(); 

Which does not work and gives me the following error in console:

Uncaught TypeError: Cannot read property 'slice' of null in kendo.all.min.js:13

I am trying to set the filter and sort parameters and update my grid in one go instead of two separate calls such as:

grid.dataSource.filter({
    field: 'branchId',
    operator: 'eq',
    value: selectedBranchId
});
grid.dataSource.sort({
    field: 'id',
    dir: 'desc'
});

I have tried:

grid.dataSource.data({
    filter: {
      field: 'branchId',
      operator: 'eq',
      value: selectedBranchId
    },
    sort: {
      field: 'id',
      dir: 'desc'
    }
})
  grid.dataSource.read(); 
  grid.refresh(); 

Which does not work and gives me the following error in console:

Uncaught TypeError: Cannot read property 'slice' of null in kendo.all.min.js:13
Share Improve this question asked Feb 25, 2013 at 12:52 imperium2335imperium2335 24.2k38 gold badges116 silver badges194 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

To bine several operations into one use the query method.

query is what you need.

Another workaround is set filter and sorting indirectly and then call fetch method when needed:

dataSource._filter = yourFilter;
dataSource._sort = yourSort;
dataSource.fetch();

second case may be useful when your dataSource already contains query settings like page, take, skip. They will be overwrited by query method, but keeps the same via setting filter/ sorting indirectly.

发布评论

评论列表(0)

  1. 暂无评论