简体   繁体   English

从V8分页升级到V15后,ag-grid无法正常工作。 初始加载后未执行数据源

[英]ag-grid after upgrade from V8 to V15 pagination is not working properly,. Data source is not executed after initial loading

Background 背景

Had upgraded the typescript to 2.6.2 from 2.3.4. 已将打字稿从2.3.4升级到2.6.2。 Ag grid have compile issue so its upgraded to 15.0.0. Ag网格存在编译问题,因此将其升级到15.0.0。 After upgrade existing pagination code for ag-grid is not working. 升级后,ag-grid的现有分页代码不起作用。

Previous Configuration - ag-grid and pagination works fine 以前的配置 -农业网格和分页效果很好

on click search button from form searchCategory() method will be called and load the grid 在窗体SearchCategory()方法上单击搜索按钮时,将调用并加载网格

package.json 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 temp.html

New Configuration Details 新配置详细信息

package.json package.json

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

test.ts pagination replaced with infinite. 用无限替换test.ts分页。

/* rowModelType: 'pagination',*/ rowModelType: 'infinite', pagination: true, / * rowModelType:“分页”,* / rowModelType:“ infinite”,分页:true,

Current Behavior 当前行为

On call to searchCategory(), server call is made and data loaded into grid with pagination bar. 调用searchCategory()时,将进行服务器调用,并使用分页栏将数据加载到网格中。 On clicking next in the pagination bar, its not calling the registered data source and halt there. 在分页栏中单击“下一步”时,它不会调用已注册的数据源并停在那里。

Expected Behaviour pagination should work properly. 预期行为分页应正常工作。 Datasource should be called on next & prev and update the grid 下一个和上一个应该调用数据源并更新网格

use other pagination libraries to solve this issue, Here primeng pagination, 使用其他分页库来解决此问题,请在这里启动分页,

https://www.primefaces.org/primeng/#/paginator https://www.primefaces.org/primeng/#/paginator

//html // html

<div *ngIf="totalRecords > catPaginationSize">
                 <p-paginator rows="10" totalRecords="{{totalRecords}}"   (onPageChange)="paginate($event)" ></p-paginator>
           </div> 

//ts // ts

import { PaginatorModule } from 'primeng/primeng';

 paginate(event: any) {
        this.startIndex = event.first;
        this.rowsPerPage = event.rows;
        this.paginatedList();
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM