How can I get all the rows of ag-grid?

前端 未结 4 1390
名媛妹妹
名媛妹妹 2021-02-19 09:57

ag-grid provides a way to get selected rows using api.getSelectedRows() function. And provides a way to set all rows using api.setRowData([]) function.

4条回答
  •  情书的邮戳
    2021-02-19 10:37

    Ag-grid doesn't provide any method to do that. You can check it here Accessing Data Ag-grid and here Grid Api.

    I guest the reason is because you can do it through a loop, as you mentioned before.

    let items: Array = [];
    this.gridApi.forEachNode(function(node) { 
        items.push(node.data);
    });
    

    Or if the source of your ag-grid is linked through angular there is no need to loop over the grid (assuming that the data grid has not pending changes)

提交回复
热议问题