【发布时间】:2016-11-02 19:55:40
【问题描述】:
angular2 ag-grid 分页的任何示例,尤其是在虚拟分页/无限滚动上?我已经搜索了一段时间,没有发现任何有用的东西。非常感谢任何帮助!
这是我的html:
<ag-grid-ng2 #agGrid class="ag-fresh" style="height: 300px"
[gridOptions]="gridOptions"
[rowGroupPanelShow]="always"
[columnDefs]="columnDefs"
[datasource] = "dataSource"
rowModelType = "virtual"
enableFilter
enableSorting
enableColResize
(modelUpdated)="onModelUpdated()"
>
</ag-grid-ng2>
这是我在控制器中的数据源方法:
private createDataSource() {
if (!this.rowData) {
//in case user selected 'onPageSizeChanged()' before the json was loaded
return;
}
console.log("this.rowData " + this.rowData.length);
console.log("Obtaining datasource");
this.dataSource = {
rowCount: null, // behave as infinite scroll
pageSize: 2,
overflowSize:1,
getRows: function (params) {
console.log('asking for ' + params.startRow + ' to ' + params.endRow);
// At this point in your code, you would call the server, using $http if in AngularJS.
// To make the demo look real, wait for 500ms before returning
setTimeout(function () {
// take a slice of the total rows
var rowsThisPage = this.rowData.slice(params.startRow, params.endRow);
// if on or after the last page, work out the last row.
var lastRow = -1;
if (this.rowData.length <= params.endRow) {
lastRow = this.rowData.length;
}
// call the success callback
params.successCallback(rowsThisPage, lastRow);
}, 500);
}
}
}
【问题讨论】:
-
请在此处描述您的具体问题。
标签: angular pagination ag-grid