1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

serverSideDataSource triggering twice in ag-grid

Discussão em 'Angular' iniciado por vijesh, Agosto 22, 2025.

  1. vijesh

    vijesh Guest

    serverSideDataSource triggering twice in ag-grid, When the filter set on session and reloading the window. The below method triggering twice

    serverSideDataSource(count: number) {
    return {
    getRows: (params) => {
    //add sortModel for dynamically created columns
    params.request.sortModel.forEach((sortItem) => {
    if (sortItem.colId.split('&').length > 1) {
    const sortModelObj = {};
    sortItem.colId.split('&').forEach((subCol) => (sortModelObj[subCol] = { ...sortItem, colId: subCol }));
    params.request.sortModel = Object.values(sortModelObj);
    }
    });
    const sortModel = Object.keys(params.request.sortModel);
    let where = this.whereBy;
    if (this.filterStateWhere.length !== 0) {
    where = [...this.whereBy, ...this.filterStateWhere];
    const mainFilterModel = this.gridApi.getFilterModel();
    const filterStateModel = JSON.parse(this.cacheSvc.getState('session', `${this.viewType}/${'FilterState'}`));
    params.request.filterModel = { ...mainFilterModel, ...filterStateModel };
    }
    const filterModel = Object.keys(params.request.filterModel) as string[];
    this.payload = getDefaultPayload({
    params,
    gridOptions: this.gridOptions,
    order: this.orderBy,
    where,
    select: this.selectBy
    });
    this.payload.limit = this.gridOptions.paginationPageSize;
    // main server request
    if (filterModel.length !== 0) {
    this.filterChecks(params, filterModel, sortModel);
    } else {
    if (sortModel.length !== 0) {
    this.payload.offset = this.gridApi.paginationGetCurrentPage() > 0 ? params.request.startRow : 0;
    this.payload = this.applySortPayload(params.request.sortModel);
    }
    this.togglePagination(count);
    this.fetchItemsRequest(params, count);
    }
    }
    };
    }

    Continue reading...

Compartilhe esta Página