Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

agSetColumnFilter was getting error for server side pagination

Tags:

ag-grid

agSetColumnFilter was getting error for server side pagination as "Set Filter cannot initialise because you are using a row model that does not contain all rows in the browser. Either use a different filter type, or configure Set Filter such that you provide it with values".

I had specified

enableServerSideSorting: true,
enableServerSideFilter: true,
rowModelType: 'infinite' 

and added

filter: "agSetColumnFilter". 

But still I was getting the error.

How to overcome from this issue(In react application)?

like image 453
Antony Thanislas Avatar asked Jul 26 '26 14:07

Antony Thanislas


2 Answers

When you use rowModelType = "infinite" ag-grid's set filter does not work. If you want to use serverside pagination you need to set rowModelType = "serverSide". So you have to use simple column filters Text Filter, Number Filter or Date Filter.

Set the filter value text in column definition. e.g.

this.state = {
      columnDefs: [{
        field: 'AtheleteName',
        filter: 'text'
      },
      {
        field: 'Age',
        filter: 'number'
      },
      {
        field: 'Date',
        filter: 'date'
      }]
}

Ref - Provided simple filters Server side operations

like image 178
Dipak J Avatar answered Jul 30 '26 09:07

Dipak J


You can use the set filter with server side data, but you have to implement the datasource by supplying a values function to your filterParams see docs.

An example of how to achieve this can be found here

const gridOptions = {
    columnDefs: [
        {
            filter: 'agSetColumnFilter',
            filterParams: {
                values: params => {
                    // async update simulated using setTimeout()
                    setTimeout(() => {
                        // fetch values from server
                        const values = getValuesFromServer();
                        // supply values to the set filter
                        params.success(values);
                    }, 3000);
                }
            }
        }
    ]
}
like image 32
VanDerNorth Avatar answered Jul 30 '26 09:07

VanDerNorth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!