2

If a grouping aggregator is defined for an editable column, when an edit for that column is committed, by default the grouping total for that column does not update.

In the following code sample, I can call dataView.refresh() whenever an edit is commited for a certain column, but this will recalculate the grouping aggregator totals for all the columns with grouping aggregators.

grid.onCellChange.subscribe(function (e, args) {
    var dataView = grid.getData();
    var column = grid.getColumns()[args.cell];
    if (column.id === 'MyEditableColumn') {
        dataView.refresh();
    }
});

For thousands of data items and many grouping aggregators, this could be computationally heavy in older browsers, especially if it's going to happen after every edit in a column with a grouping aggregator. Is there a way to recalculate a single grouping aggregator for only one column?

4

1 回答 1

5

首先,如果您使用的是 DataView,您应该通知它该特定项目的更新:

grid.onCellChange.subscribe(function (e, args) {
  dataView.updateItem(args.item.id, args.item);
});

现在,按照现在的实现方式,它将导致完全重新计算(而不仅仅是聚合器 - 过滤器、组等;所有这些都可能由于项目的变化而改变!),这通常很快在更旧的浏览器中至少足以容纳 50'000 行。将重新计算限制为仅特定列更改是行不通的。

于 2013-11-06T19:54:27.667 回答