Reputation: 105
I am using ag grid (angular2) for rendering table and uses valueGetter feature to render row data to ui.
I would like to add onscroll pagination to my ui, but couldn't find a way to use datasource.
`gridOptions.api.setDatasource(ds);`
How to collaborate valueGetter and pagination here?
valueGetter code
this.gridData = {cols:["col1", "col2"], rows:[["data1","data2"],
["data3","data4"]]};
this.columnDefs = [];
this.rowData = this.gridData.rows;
for (var i in this.gridData.cols){
var scopeOutCurrIndex = i => (params) => params.data[i]
this.columnDefs.push({
headerName: this.gridData.cols[i],
valueGetter: scopeOutCurrIndex(i)
})
}
Upvotes: 0
Views: 438
Reputation: 105
This is straightforward, one can use the same implementation to achieve this:
var dataSource = {
data: gData,
rowCount: null,
getRows: function (params) {
console.log("asking for " + params.startRow + " to " + params.endRow);
var rowsThisPage = this.data.slice(params.startRow, params.endRow);
var lastRow = -1;
if (this.data.length <= params.endRow) {
lastRow = this.data.length;
}
params.successCallback(rowsThisPage, lastRow);
}
};
this.gridApi.setDatasource(dataSource);
Upvotes: 1