I am using ag-grid-react
in my application. There is one feature, after changing the database path in the application, and after pressing the refresh button it should load new data.
To achieve this I am using refreshInfiniteCache
in componentwillreceiveprops
, so when props will change( using redux), it should refresh data.
please find below code,
componentWillReceiveProps(nextProps) {
this.gridApi.refreshInfiniteCache();
console.log("received");
}
onGridReady(params) {
this.gridApi = params.api;
this.gridColumnApi = params.columnApi;
params.api.sizeColumnsToFit();
window.onresize = () => {
this.gridApi.sizeColumnsToFit();
};
var current = this;
const updateData = data => {
data.forEach(function (data, index) {
data.id = "R" + (index + 1);
});
var dataSource = {
rowCount: null,
getRows: function (params) {
current.setState({
paramsparameter: params
})
var Apiinput = apiinput(params.startRow, params.sortModel, params.filterModel, current.state.restore, current.state.removeallrecords);
var res = request('POST', 'http://localhost:4000/paginatedata', { json: Apiinput });
var returnfilterdata = JSON.parse(res.getBody('utf8'));
var lastRow = -1;
if (returnfilterdata.length < 100) {
console.log("entered last row");
lastRow = returnfilterdata.length;
}
params.successCallback(returnfilterdata, lastRow);
}
};
params.api.setDatasource(dataSource);
};
updateData(this.state.rowData);
}
But it is not loading new data. I do not know what am I doing wrong here.
Thanks Mangesh