I am new to Ag-grid-react. Currently, there is a simple react table in the App that works fine but it doesn't have the powerful functionality like Ag-grid. I am thinking of switching to Ag-grid-react.
However, during the implementation. I found that when I update props from my outside data source into Ag-grid. Ag-grid-react will automatically re-render the whole table and forget the previous settings.
I Use Meteor 1.4 as the platform, React 15.4.2 as framework.
Questions: this.props.data is my outside data source that I am going to display. It works well for first rendering but when I change a cell value from outside. This props change. And it will re-render the table. How do I avoid automatically re-render and only change the cell value that I have changed?
I see in the document there is API to call and make the change of row data in Ag-grid. If I use API, then every time my data changed will need to do a prev props and current props check in the data source and use API to send the change to Ag-grid. Is it supposed that React will do check automatically and re-render only the children component that I have changed?
Let me know if any solution to solve this problem.
Partial Code:
class MasterDetailExample extends Component {
constructor(props) {
super(props);
this.state = {
rowData: this.props.data,
columnDefs: this.createColumnDefs(),
};
this.onGridReady = this.onGridReady.bind(this);
}
onGridReady(params) {
this.gridApi = params.api;
this.columnApi = params.columnApi;
}
...//Some code for createColumnDefs()
isFullWidthCell(rowNode) {
return rowNode.level === 1;
}
getRowHeight(params) {
let rowIsDetailRow = params.node.level === 1;
return rowIsDetailRow ? 200 : 25;
}
getNodeChildDetails(record) {
if (record.callRecords) {
return {
group: true,
key: record.name,
children: [record.callRecords],
};
} else {
return null;
}
}
render() {
return (
<div style={{height: 1000 , width: "100%" }}
className="ag-fresh">
<AgGridReact
columnDefs={this.state.columnDefs}
rowData={this.state.rowData}
isFullWidthCell={this.isFullWidthCell}
getRowHeight={this.getRowHeight}
getNodeChildDetails={this.getNodeChildDetails}
fullWidthCellRendererFramework={DetailPanelComponent}
enableSorting
enableColResize
suppressMenuFilterPanel
onGridReady={this.onGridReady}>
</AgGridReact>
</div>
);
}
};
deltaRowDataMode
that may answer your question. Last paragraph of the page. – JulienD