ag-grid-angular-example icon indicating copy to clipboard operation
ag-grid-angular-example copied to clipboard

ag-grid upgrade to v15, pagination not working. Data source execute only once.

Open roshenpo007 opened this issue 8 years ago • 1 comments

Background

Had upgraded the typescript to 2.6.2 from 2.3.4. Ag grid have compile issue so its upgraded to 15.0.0. After upgrade existing pagination code for ag-grid is not working.

Previous Configuration - ag-grid and pagination works fine

on click search button from form searchCategory() method will be called and load the grid

package.json

"ag-grid": "^8.1.0",
"ag-grid-angular": "^8.1.0",
.....
 "typescript": "^2.3.4"

temp.ts


 gridOptions = <GridOptions>{
        context: {},
        paginationPageSize: AppUtils.IR_PAGINATION_SIZE,
/*        rowModelType: 'pagination',*/
        rowModelType: 'infinite',
        pagination: true,
        enableServerSideSorting: true,
        suppressDragLeaveHidesColumns: true,
        onGridSizeChanged: () => {
            this.gridOptions.api.sizeColumnsToFit();
        },
        getRowHeight: () => {
            return 32;
        },
         components: {
              getTypeDesc : function(params: any) {
        var eDiv = document.createElement('div');
        let desc = params.context.typeMaster.filter(function (item: any) {
            if (params.data.typeCode === item.typeCode) {
                return item.typeDescription;
            }
        });
        eDiv.innerHTML = '<span>' + desc[0].typeDescription + '</span>';
        return eDiv;
    },


    };
    typeMaster: TypeMasterModel[];
    categoryMaster: CategoryModel[];
    category: CategoryModel = new CategoryModel();
    severityMaster: SeverityMasterModel[];
    selectedRowsValue: number[];
    columnDefs: any[] = [
        { headerName: '', field: 'catCode', hide: true },
        { headerName: 'Category', field: 'catDesc', width: 550 },
        { headerName: 'Type', field: 'typeCode', cellRenderer:'getTypeDesc' }
        { headerName: 'PatientID', field: 'patIdMandYn' },
        { headerName: 'EquipmentID', field: 'equipIdMandYn' },
        { headerName: 'WorkorderId', field: 'workOrderMandYn' }
    ];
    action: string = '';


searchCategory() {
        let self = this;
        let dataSource = {
           rowCount: null, // 
            getRows: (params: any) => {
                this.http.get(//server call ).subscribe(res => {
                    let result = res['result'];
                    if (result != null && result.paginatedList != null) {
                        this.totalRecords = result.paginatedList.length;
                        if (this.totalRecords <= 0) {
                            this.gridStatusMessageDisplay("");
                        }
                        params.successCallback(result.paginatedList, result.totalRecords);
                    } else {
                        this.gridStatusMessageDisplay("");
                    }
                });
            }
        }
        this.gridOptions.api.setDatasource(dataSource);
    }

temp.html

 <ag-grid-angular #agGrid style="width:100%; height: 400px" class="ag-fresh" [gridOptions]="gridOptions" [columnDefs]="columnDefs"
        enableColResize rowSelection="multiple" ></ag-grid-angular>

New Configuration -

package.json

"ag-grid": "^15.0.0",
 "ag-grid-angular": "^15.0.0",
 "typescript": "^2.6.2"

test.ts pagination replaced with infinite.

/* rowModelType: 'pagination',*/ rowModelType: 'infinite', pagination: true,

Current Behavior

On call to searchCategory(), server call is made and data loaded into grid with pagination bar. On clicking next in the pagination bar, its not calling the registered data source and halt there.

Expected Behaviour pagination should work properly.

roshenpo007 avatar Dec 21 '17 05:12 roshenpo007

any update on it ?

tahir-jamil avatar Oct 06 '21 11:10 tahir-jamil