首页 > 解决方案 > Viewport datamodel - GetRow().data undefined

问题描述

i'm trying to implement updates for my viewport data model, with a methodology analogous to their description in their documentation:

https://www.ag-grid.com/javascript-grid-viewport/#

Unfortunately this approach is not working for me, since:

ViewportDatasource.prototype.onDataUpdated = function (elements) {
  var that = this;
  elements.forEach(function (change) {
    console.log(JSON.stringify(change))
    console.log('change.Id: ' + change.Id)
    var rowNode = that.params.getRow(change.Id);
    if (!rowNode || !rowNode.data) {.....}
}

always fails, as rowNode.data is always undefined (there is data in the model, as the basic grid itself is shown up fine). The rowNode itself is returned fine.

According to this, calls to rowNode.setData(..) rowNode.setDataValue('..', '...') are also failing.

Do you have any advise, how i can update single rows in viewport datamodel?

thanks in advance,

标签: javascriptangularag-grid

解决方案


基本上它是 ag-grid 中的一个错误/功能。

如果that.params.getRow(change.Id);使用唯一的行标识符调用,则返回未呈现的对象并且尚未设置数据对象。

如果that.params.getRow(change.RowIndex); 被调用,则返回一个渲染对象 -> 设置数据对象。


推荐阅读