如何 select Kendo UI 网格中创建的过滤器中的所有行?

How to select all rows from a created filter in Kendo UI Grid?

我有这个 telerik 项目:https://dojo.telerik.com/@blockbaster/axIbuPOs

测试一下:

  1. 在 "Units in Stock" 列中输入值“15”。

    --> 4 个元素应该显示在 2 页上。

  2. 点击左上角的"Select all rows"复选框

    -->只添加可见元素

The selected product ids are: [26, 7]

目标:执行点 1-2

The selected product ids are: [26, 48, 7, 70]

从网格导出到Excel时,有选项:

excel: {
  allPages: true
}

这个也有选项吗?

注意:目前还没有服务器分页。所有数据将立即加载。

基本步骤是:

  1. 将 Grid 的 persistSelection 配置设置为 true。
  2. 使用jQuery select或订阅主复选框的点击事件。
  3. 在点击事件处理程序中

    3.1 使用KendoUIdataSource.UI的pageSize方法将当前页面大小保存在全局变量中。

    3.2 使用 pageSize 方法在一个页面上显示所有行。

    3.3 Select 使用 Kendo UI 网格的 select 方法的所有行。

    3.5 使用 pageSize 方法恢复旧页面大小。

    函数 onClick(e) { var grid = $("#grid").data("kendoGrid");

        oldPageSize = grid.dataSource.pageSize();
        grid.dataSource.pageSize(grid.dataSource.data().length);
    
        if (grid.dataSource.data().length === grid.select().length) {
            grid.clearSelection();
        } else {
            grid.select("tr");
        };
    
        grid.dataSource.pageSize(oldPageSize);
    };
    

Telerik 在文档中有一个 selection 跨网格页面的示例 here