What could be causing the request parameter in my ag-grid to be undefined?

Currently experimenting with the ServerSide RowModel of Ag-Grid in combination with Angular. Planning to add server response later on, but for now focusing on familiarizing myself with the framework. Struggling to retrieve request parameter values from my grid using

console.log(Start Row: ${params.request.startRow}, End Row: ${params.request.endRow})
as I keep getting undefined for both params. Any insights into what might be causing this issue?

export class TestComponent implements OnInit {

  gridApi!: GridApi;

  columnDefs: ColDef[] = [
    {field: 'firstName'},
    {field: 'lastName'},
  ];

  gridOptions: GridOptions = {
    columnDefs: this.columnDefs,
    rowModelType: 'serverSide',
    cacheBlockSize: 5,
    maxBlocksInCache: 1,
    sideBar: true,
  }
  
  constructor() {
  }

  ngOnInit(): void {
  }

  dataSource: IServerSideDatasource = {
    getRows: (params: IServerSideGetRowsParams) => {
      console.log(`Start Row: ${params.request.startRow}, End Row: ${params.request.endRow}`)
      params.success({
        rowData: [{firstName: "Test", lastName: "test"},
          {firstName: "test", lastName: "test"},]
      })
    }
  }

  
  onGridReady(event: AgGridEvent) {
    this.gridApi = event.api
    this.gridApi.setServerSideDatasource(this.dataSource);
  }

Here's a snippet from my TestComponent html file:

<ag-grid-angular
  style="width: 100%; height: 800px"
  class="ag-theme-alpine-dark"
  [gridOptions] = "gridOptions"
  (gridReady)="onGridReady($event)"
>
</ag-grid-angular>

Answer №1

While inside the onGridReady event, make sure to access the gridApi on the provided gridOptions as shown below:

onGridReady(event: AgGridEvent) {
    this.gridOptions.api?.setServerSideDatasource(this.dataSource);
  }

It is important to note that according to the official documentation of ag-grid, when passing grid configurations using gridOptions, we should call the grid api on gridOptions specifically.

For more information, refer to this link - https://www.ag-grid.com/angular-data-grid/grid-interface/

If you encounter any further difficulties, please do not hesitate to reach out for assistance.

Thank you.

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

Error message: When attempting to create dynamic inputs in React, an error occurs stating that instance.render is not

I encountered an issue while attempting to create dynamic inputs in React. The error message 'TypeError: instance.render is not a function' keeps popping up. import React, { Component } from 'react'; import Input from '../../Ui/Inp ...

V-Calendar is not displaying the accurate dates

https://i.stack.imgur.com/zk4h7.png The image displays dates starting on June 1, 2022, which should be a Wednesday but appears as a Sunday on the calendar. This issue affects all months as they start on a Sunday instead of their respective weekdays. The p ...

Is there a way to override the JSON.stringify method within the JSON class of a TypeScript project without using a custom call?

Dealing with a React Native and TypeScript app here. I keep encountering an error from Fabric every week: "JSON.stringify cannot serialize cyclic structures." The frustrating part is that the error seems to pop up randomly, without any specific scenario tr ...

Update the react component's state props to trigger a re-render when the state changes

I'm facing an issue with getting a component to rerender in React even though one of its components is a piece of state that receives updates. The piece of state in question is 'board': const [board, setBoard] = useState("") The component i ...

Experiencing an issue with mui/material grid causing errors

An error occurred in the file Grid2.js within node_modules/@mui/material/Unstable_Grid2. The export 'createGrid' (imported as 'createGrid2') could not be found in '@mui/system/Unstable_Grid' as the module has no exports. Desp ...

Coat the div with a uniform shade of pure white

I need assistance on applying a solid white background color to hide the text behind it. For better understanding, I have attached a screenshot as a reference. https://i.stack.imgur.com/f8Qd9.png The issue arises when I click on the dropdown in the heade ...

Getting form field values with JQuery

I am currently facing an issue with a form field in HTML. Here is the code snippet: <form id="tasklist"> <input type="text" id="name" ...></input> ... additional form elements go here ... </form> Although I am trying to retrie ...

Converting a dynamic JSON object into a generic type in TypeScript

I need assistance with converting a JSON object into the equivalent generic type in TypeScript. The JSON object I have contains dynamic keys such as applications and permissions. The keys inside applications, like application_management and user_managemen ...

What is the counterpart of the JavaScript transport.responseText in jQuery's Ajax requests?

I'm currently in the process of converting my JavaScript Ajax request to jQuery's ajax. Here is an example of my existing JavaScript Ajax code: new Ajax.Request(url, { method: 'post', onSuccess: function(transport) { ...

"Unfortunately, Azure Web Static Apps do not have the capability to access .env files that are prefixed with NEXT

Suppose I have an .env file set up like this: NEXT_PUBLIC_API_BASE_PATH = value1 While this .env is functioning correctly in my local environment, once deployed to Azure Web Static Apps and added to the configurationhttps://i.sstatic.net/eqiYn.png My app ...

Twice the clicking actions triggered by the event

Whenever I try to trigger a function by clicking on the label text, the click event seems to be firing twice. HTML <label class="label_one"> Label One <input type="checkbox"/> </label> However, if I modify the HTML code as f ...

Having troubles with angular due to doodle throwing errors?

https://codepen.io/tuckermassad/pen/rPYNLq I took the CSS doodle code from the above link and incorporated it into my angular component: <section class="main"> <css-doodle grid="5"> :doodle { @grid: 10 / 100%; } ...

Retrieve the initial link value in jQuery and make changes to it

Is there a way in jQuery to append to the current value of an attribute without storing it in a variable first? For example: $(document).ready(function() { $("#btn").click(function() { // get the link currently var linkCurrent = $("#link").att ...

Using JavaScript to enhance event handling for a `select` element in a progressive manner

I have an advanced <select> element in my HTML. It is structured like this: <ul> <li></li> <li></li> ... </ul> In the current setup, a click event handler is attached to each individual li element. If the ...

Is idempotency achievable with nested arrays in MongoDB?

I am currently working on developing a REST API and striving to ensure it is idempotent. One area where I am facing difficulties is with nested arrays and maintaining idempotency. I am specifically interested in updating an item within the product_notes ar ...

When attempting to call a script function in PHP and expecting a return value, an error was encountered: "Uncaught SyntaxError

My functions are working fine: <script> function createCookie(name,value,sec) { if (sec) { console.log('createCookie: '+name+', '+value+', '+sec); var date = new Date(); date.setTime(date.getTime()+(sec*1000 ...

Ways to divide a buffer in JavaScript

String was created by utilizing the toString method on the buffer. Here is a sample of the resulting string: GET / HTTP/1.1 Host: localhost:8080 Connection: keep-alive Cache-Control: max-age=0 .... Is there a way to parse this string whenever a space (" ...

The View is not reflecting changes in the Variable

Is there a way to disable all the buttons when selectedplace is null in the Dialog, as it currently works when the Dialog first starts but remains activated all the time when the option is changed? I have attempted the following: Customized HTML: ...

How should one properly format an array of objects with elements that are different types of variations?

I am currently developing a versatile sorting module using TypeScript. This module will take in an array of data objects, along with a list of keys to sort by. Once the sorting process is complete, the array will be sorted based on the specified keys. To ...

Get an Array Using AJAX in PHP and JavaScript

Section 1 I want to retrieve an Array from PHP and use it in JavaScript. I have created a file using the fwrite function in PHP, then included that file in my next .load method inside a Div. The new PHP file contains an "include 'somefile.php';" ...