Deepak Anuraag
Deepak Anuraag

Reputation: 61

Filtering on ag-grid serverside not setting start row to 0 and end row to 100

Really need help on this, please.

Brief: I have implemented ag-grid serverside mode with partial store for lazy loading.

Problem Scenario : ServerSide mode, what happens is as you scroll more data is loaded, in terms of ag-grid more row blocks are loaded.

Lets say block size is 100 rows. I scrolled 5-6 times, 5-6 request went to the server , loaded the data into the grid using success callback of getRows method in ServerSideDataSource Implementation.

You are currently viewing 500th-600th row in your viewport(the last request that went to server).

If you go and apply a fresh/change-existing filter on a column, the getRows method will get called but with request params having startRow 500 and endRow 600(rowBlock you are currently viewing).

This is the issue. I want that to be 0 and 100 respectively as you generally implement server-side filtering. It should be a fresh request to server right. ag-grid should recognise a new filter got applied so dump the existing rows on the grid send fresh request to server with 0 and 100 values.

This start and end row values are fine when you have already loaded data with filter applied till 500 and scrolling to load 500-600. But when the filter is first applied/ freshly applied(change from existing filter/ newly applied) you need the start and end rows to be 0 and 100 right. Help!!

Upvotes: 1

Views: 3313

Answers (2)

belivine
belivine

Reputation: 31

I got a method,after filter changed grid will be scrolled to the first row.

Angular :

    filterChanged(params: FilterChangedEvent): void {
       this.gridApi.ensureIndexVisible(0,null);
    }

Javascript :

    filterChanged(params) {
       gridOptions.api.ensureIndexVisible(0,null);
    }

Upvotes: 1

kifni41
kifni41

Reputation: 76

Hi i came across this question while searching for this exact problem, looking around to the docs and couldn't find solution there. It's happening after they introduce serverSideStoreType: "partial | full".

my current workaround for this is to updating params.request.filterModel on your getRows datasource, if detect any changes on filterModel

getRows: function (params) {
  //update startRow to 0 then detect changes
  if(grid.filterModel != JSON.stringify(params.request.filterModel) ){
    params.request.startRow = 0;
  }
  grid.filterModel =  JSON.stringify(params.request.filterModel);


Upvotes: 2

Related Questions