gpt4 book ai didi

javascript - 如何在排序时同步 Kendo UI 网格数据源?

转载 作者:行者123 更新时间:2023-11-30 17:36:05 24 4
gpt4 key购买 nike

好的,所以我们有一些使用 Kendo UI 网格的遗留代码。

对网格进行排序后,我们需要能够读取对应于每一行的数据源项,方法是遍历 JQuery 选择的“tr”列表,然后根据行本身的索引选择数据源项。

存在的问题是在网格排序的时候DataSource并没有排序,所以不能简单的获取每行的索引然后查找对应的DataSource项,像这样...

    $('td:nth-child(' + colIndex + ')', $('tbody', grid.element).eq(0)).each(
function (iIndex) {
var td = $(this);
var tr = td.parent();
var data = grid.dataSource.data()[iIndex];

if (data.Status.toLowerCase() !== 'c') {
totalBalanceDue = (totalBalanceDue - data.Payment) > 0 ? (totalBalanceDue - data.Payment) : 0;
};
td.html('$' + totalBalanceDue.formatMoney(2, '.', ','));
}
);

最佳答案

这都不需要。您只需要使用 view () 数据源的方法。

关于javascript - 如何在排序时同步 Kendo UI 网格数据源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22018583/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com