ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: pranit@srcomsec on November 18, 2022, 12:19:06 pm

Title: Get list of rows which is visible in grid with lazy/remote loading
Post by: pranit@srcomsec on November 18, 2022, 12:19:06 pm
Please advise how to get a list of rows visible on the grid.

For example, the data model with gird is 2000 rows, the grid height can be changed anytime.

If the grid shows 20 rows after adjusting the height then it returns 20 rows only, If the grid shows 30 rows after adjusting height then returns 30 rows.


Title: Re: Get list of rows which is visible in grid with lazy/remote loading
Post by: paramvir on November 21, 2022, 06:49:21 am
Visible row indices can be obtained by getViewPortIndx method.

https://paramquery.com/pro/api#method-getViewPortIndx
Title: Re: Get list of rows which is visible in grid with lazy/remote loading
Post by: pranit@srcomsec on November 22, 2022, 05:54:59 pm
Thank you for this, with this method we are getting an index of the start and end rows. If we need to get data for the start & end row index then we need to loop and get all details.

I am using the method below to get these rows. Please advise if you see this is not correct.
Code: [Select]
var loGridSymbols = $("#gridfilter1").pqGrid("getData", { dataIndx: ['stExchange', 'stSymbol', 'pq_empty'] });
var loActiveRows = loGridSymbols.filter((x) => { return x.pq_empty == false; });
Title: Re: Get list of rows which is visible in grid with lazy/remote loading
Post by: paramvir on November 22, 2022, 07:25:00 pm
That's incorrect.

Row data can be obtained from rowIndx by pageData[ rowIndx ]. So first and last visible row in the viewport can be obtained as:

Code: [Select]
var pageData = grid.pageData();
var firstRow = pageData[ obj.initV ];
var lastRow = pageData[ obj.finalV ];

where obj is returned by getViewPortIndx method.
Title: Re: Get list of rows which is visible in grid with lazy/remote loading
Post by: pranit@srcomsec on November 22, 2022, 08:32:34 pm
Thank you for your quick response.

As per your suggestion, we can get 1st and last row's details. We need all rows data between the start (obj.initV) and end row (obj.finalV) index.

Let me know if you have any suggestions.
Title: Re: Get list of rows which is visible in grid with lazy/remote loading
Post by: paramvir on November 22, 2022, 09:55:47 pm
you can get all rendered rows as an array with slice method.

Code: [Select]
  var renderedRows = pageData.slice( initV, finalV+1);
Title: Re: Get list of rows which is visible in grid with lazy/remote loading
Post by: pranit@srcomsec on November 23, 2022, 12:32:23 pm
That is perfect!

Thank you very much.