Events for Pagination in ag-Grid Server-side Mode

I am currently working on implementing server side pagination for my ag-Grid. The initial setup of the grid is done and it displays the data correctly when the page first loads. However, I have over 5000 records in the table and I want to fetch the next set of records from the server every time the user clicks on the next button. The issue I am facing is that the server is not being called when the next/previous button is clicked and I am unsure how to listen for pagination events to trigger another HTTP request.

Here are my Grid options:

this.gridOptions = <GridOptions>{};
    this.gridOptions = {

        enableServerSideSorting: true,
        enableServerSideFilter: true,
        enableSorting: true,
        enableFilter: true,
        enableColResize: true,
        rowSelection: 'single',
        rowDeselection: true,
        columnDefs: this.columnDefs,
        rowModelType: 'infinite',
        paginationPageSize: 35,
        maxConcurrentDatasourceRequests: 2,
        infiniteInitialRowCount: 1,
        getRowNodeId: (item: any) => {
            return item.id;
        },
        pagination: true,
        onGridReady: () => { this.gridOptions.api.sizeColumnsToFit(); },
        context: { componentParent: this },//to invoke the method of this(parent) component from child component,
        onRowClicked: (event: any) => { this.router.navigateByUrl(`/dataList/edit/${event.data.id}`); },
    };

Data source definition:

let dataSource = {
        getRows: (params: any) => {
            setTimeout(() => {

                let dataAfterSortingAndFiltering = this.sortAndFilter(allOfTheData, params.sortModel, params.filterModel);
                let rowsThisPage = dataAfterSortingAndFiltering.slice(params.startRow, params.endRow);
                
                let lastRow = -1;
                if (dataAfterSortingAndFiltering.length <= params.endRow) {
                    lastRow = dataAfterSortingAndFiltering.length;
                }

                params.successCallback(rowsThisPage, lastRow);
            }, 500);
        }
    };
    this.gridOptions.api.setDatasource(dataSource);

Answer №1

Here is a message I found in the Aggrid documentation:

Version 9.0 of ag-Grid introduced a switch from server side pagination to client side pagination. The use of server side pagination was then discontinued in version 10.1. If you were previously implementing server side pagination, it is recommended to transition to pagination with infinite scrolling as part of adapting to the new system. For those who were manually slicing data in their Datasource to simulate browser-based pagination, it is advised to utilize the default In Memory Row Model and set the row data normally while enabling the grid property pagination=true.

I suggest listening for the paginationChanged event and making an API call, followed by calling setData.

I hope this information proves useful.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Discovering how to choose an element from a list fetched through ajax in Angular

It's quite strange to me. Angular allows for selecting by reference, but not by value. Let me explain my situation: I have a form that lets users edit a model. I use ajax to fetch both the model and a list of possible values for one of the model&apo ...

The access token for Axios POST API in React is either missing, invalid, or has expired

To successfully upload an image to the server using Axios, I first need to obtain the apiKey and access_token, which I have managed to do and saved in localStorage. However, when attempting to upload an image, I encounter a "403" error message as indicated ...

Error reported: "require" identifier not found in Typescript. Issue identified in IONIC 3 development environment

Error Encountered in Typescript: Cannot Find the Name 'require' Location: C:/Users/me/project/src/pages/home/home.ts // Need to require the Twilio module and create a REST client const client = require('twilio')(accountSid, ...

Leveraging CDK Context Variables in C# Lambda Initialization Code

I have a .NET Lambda function written in C# that is implemented as a .NET Minimal API according to the guidance provided here. To define AWS resources, I am utilizing CDK (TypeScript). Within my build pipeline, there is shell scripting involved to supply ...

How can I configure Angular to redirect to an error page whenever an error is encountered in an HTTP API request?

With over 50 HTTP APIs in my application, I'm looking for a way to automatically route to a specific page whenever an error message or issue arises with one of the APIs. Instead of manually adding routing to each service, I want to find a simpler and ...

The compatibility issues between Angular 5 and materialize-css (v 1.0.0) are causing obstacles in functionality

I attempted to implement the solution found on this post: Unfortunately, the solution didn't work as expected. I am working with Angular and Typescript in my project. Here is a snippet of my Typescript class: import { Component, OnInit, AfterVi ...

Ways to implement the useEffect hook within a table component for retrieving data from the backend

I'm in the process of creating a table that displays the following information: Id quantity of books 1 XX 2 ... 3 ... ... ... The quantity of books will be retrieved from the backend using useEffect useEff ...

`json object allows for category selection in options`

Hello (please excuse my English), I have the following script: <script type="text/javascript"> $(document).ready(function() { var idPlato = decodeURI(getUrlVars()["idPl"]); var url = "http://localhost/plato-datos.php?idPla="+idPl ...

Connecting to an unfamiliar attribute of a div element using Angular 12

Looking to dynamically change the value of an attribute in my component using property binding. <div class="app-container" [data-theme]="theme"> <router-outlet></router-outlet> </div> import { Component } from ...

"Unexpected behavior: PHP+JS getElementById() function is returning an integer value instead of a

EDIT: Apologies for the PHP section not displaying correctly. I am attempting to extract a decimal value from PHP/HTML in JavaScript using getElementByID().value. However, despite the PHP value being decimal, it is represented as an integer in JavaScript ...

Issues with the "required" functionality in Angular Schema Form on select and checkbox fields are not being resolved

I am encountering difficulties with the required validation of select and checkbox fields in Angular Schema Form as a beginner. Within $scope.schema, I have a select field called designation: "designation": { "title": "Designation", "type": "sele ...

Add the Selected Value to the Title

Is there a way to dynamically add the selected value from each select element to its corresponding heading without requiring user interaction? I need this to happen as soon as the page loads. Here is an example in a jsfiddle https://jsfiddle.net/dqfvyvdt/2 ...

Block-level declarations are commonly used in TypeScript and Asp.net MVC 5

In my asp.net mvc5 project, I decided to incorporate TypeScript. I created an app.ts file and installed the nuget-package jquery.TypeScript.DefinitelyTyped. Here is a snippet of the app.ts code: /// <reference path="typings/jquery/jquery.d.ts"/> cl ...

When utilizing AJAX within a for loop, the array position may not return the correct values, even though the closure effectively binds the scope of the current value position

Is this question a duplicate of [AJAX call in for loop won't return values to correct array positions? I am following the solution by Plynx. The issue I'm facing is that the closure fails to iterate through all elements in the loop, although the ...

Issue still occurring: White screen remains on Android 5.0 devices and above

Currently, I am utilizing cordova 6 to manually hide the splashscreen using navigator.splashscreen.hide(). The application is built in angular and performs well on all android versions below 5.0. Yet, on Lollipop and Marshmallow, a white screen continues ...

Capturing user-selected option from dropdown menu using npm

I am a beginner when it comes to node.js and async programming. My current project involves creating a program that shuffles a Spotify playlist. I have managed to store the user's playlists in an array for easier access. My goal is to present this ar ...

Obtaining a roster of file names with the help of the Glob

I'm attempting to gather a list of file names in node, however I believe I am encountering a scoping problem. var files = []; glob(options.JSX_DEST + "/*.js", function (er, files) { files = files.map(function(match) { return path.relati ...

Should I utilize Next.js API route or communicate directly with Firestore from the client side?

Greetings, I am new to Next.js and have a few queries regarding utilizing Firebase authentication on both the client side and server side. My project is set up with Firebase admin and client SDKs, and I have a signup page where users provide their name, em ...

Vue's intelligent element loading feature ensures that elements that are not displayed are delayed

My Vue gallery component includes a lightbox feature defined by the following code: <div id="lightbox" class="modal" v-if="photo !== null" v-show="showModal" @click.self="closeModal"> <div clas ...

Discovering the flaw in my programming that pertains to JSON parsing

After countless hours of searching and reviewing documentation, I am still unable to identify the issue with my jQuery code. My goal is to practice reading a local JSON file and displaying its contents in the body of my HTML document. $(document).ready(fu ...