Kendo UI 读取未从网格获取当前数据

发布于 2025-01-12 12:14:00 字数 549 浏览 2 评论 0原文

我有一个网格,其中包含 Id 列表,其中一个按钮包含状态(布尔 Y/N), 我通过单击按钮来调用一个函数来获取正在从网格加载数据的所有 N 个 Id。

function getAll(){

                        var page =  $("#grid").data("kendoGrid").dataSource.page();
                        console.log(page);
                        var onlyFailedIds = $('#grid').data("kendoGrid").dataSource.read().then(function(){console.log(dataSource.view()[0].items.filter(row=>row.status==='N').map(row=>row.Id) )});
                        
               }

问题是,即使我更改网格页面,我总是得到第 1 页的结果。 如何从其他页面获取结果?

I have a grid that contains a list of Id's with a button which contains state (Boolean Y/N) ,
I am calling a function at the click of a button to get all N Id's which is loading data from the grid.

function getAll(){

                        var page =  $("#grid").data("kendoGrid").dataSource.page();
                        console.log(page);
                        var onlyFailedIds = $('#grid').data("kendoGrid").dataSource.read().then(function(){console.log(dataSource.view()[0].items.filter(row=>row.status==='N').map(row=>row.Id) )});
                        
               }

The problem is that I am always getting results of page 1 even when I change the page of grid.
How do I get results from other pages?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑叹一世浮沉 2025-01-19 12:14:00

您正在使用 DataSource 的视图方法。根据文档

返回与当前页面、过滤器、排序和分组配置对应的数据项。

您应该使用 DataSource 的 data 方法。根据文档

获取或设置数据源的数据项。

例如:

const grid = $('#grid');
if (!grid) { return; }

const gridKendoGrid = grid.data('kendoGrid');
if (!gridKendoGrid) { return; }

const dataSource = gridKendoGrid.dataSource;
if (!dataSource) { return; }

dataSource.read().then(() => {
    const data = dataSource.data();
    if (!data) { return; }

    const failedIds = data
        .filter(row => row.status === 'N')
        .map(row => row.Id);
    console.log(failedIds);
});

You are using DataSource's view method. According to the documentation:

Returns the data items which correspond to the current page, filter, sort, and group configuration.

You should be using the DataSource's data method. According to the documentation:

Gets or sets the data items of the data source.

For example:

const grid = $('#grid');
if (!grid) { return; }

const gridKendoGrid = grid.data('kendoGrid');
if (!gridKendoGrid) { return; }

const dataSource = gridKendoGrid.dataSource;
if (!dataSource) { return; }

dataSource.read().then(() => {
    const data = dataSource.data();
    if (!data) { return; }

    const failedIds = data
        .filter(row => row.status === 'N')
        .map(row => row.Id);
    console.log(failedIds);
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文