AG Grid inserting rows with applyTransaction

♀尐吖头ヾ 提交于 2020-06-29 04:19:18

问题


Is there a way to insert rows at a specific index rather than at the end of the grid?

Example would if I want to insert a row 10 rows from the top? Or in the middle?

I did find an old ag grid method called insertItemAtIndex(index, [rows]);

but this isn't working and says it's deprecated. Is there a way to do this with applyTransaction(transaction)?


回答1:


The RowDataTransaction interface has an optional addIndex property -

export interface RowDataTransaction {
    /** deprecated */ addIndex?: number;
    add?: any[];
    remove?: any[];
    update?: any[];
}

Although it is marked deprecated, it is working for me.

Usage : this.gridApi.applyTransaction({ add: newItems, addIndex: 2});

It denotes the index from which new rows will be inserted.

I have tried playing around on this example from docs and is working fine.

A related question for old way of updating rows. (without transaction)



来源:https://stackoverflow.com/questions/62238792/ag-grid-inserting-rows-with-applytransaction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!