ParamQuery grid support forum

General Category => Help for ParamQuery Grid (free version) => Topic started by: omeroon on May 22, 2023, 02:15:58 am

Title: How to set checkboxes outside the viewport when using virtualX/virtualY?
Post by: omeroon on May 22, 2023, 02:15:58 am
Hi there!

I am building a large grid (=20000 records or more with 20-30 columns): it is 5 columns with filterable data and then 20-25 columns of checkboxes.
I have made a simple toggle function that will allow the user to make a selection and then toggle all checkboxes in the selection with the rightMousebutton.

Code: [Select]
let selectionArr =  myGrid.pqGrid( "selection",
   type: 'cell', method: 'getSelection' }
);

for (var i = 0; i < selectionArr.length; i++) {
   let value = myGrid.pqGrid(  "getCell", { rowIndx: selectionArr[i].rowIndx, dataIndx: selectionArr[i].dataIndx, refresh: true } );
   $(value[0]).find('input').trigger('click');
}


This works very well, however only on the items within the viewport as I am using virtualX and virtualY (without it it becomes too slow). The selection outside of the viewport is still selected, but none of the checkboxes are rendered in virtualX/virtualY so they can't be clicked. I had hoped I could get the data using something like:

Code: [Select]
myGrid.pqGrid( "data", {rowIndx: selectionArr[1].rowIndx} ).data;

But that seems to be empty.

What would be the best solution for this?
Title: Re: How to set checkboxes outside the viewport when using virtualX/virtualY?
Post by: paramvir on May 23, 2023, 10:48:55 pm
you can get the corresponding row data to set the value of fields bound to checkboxes.

https://paramquery.com/api#method-getRowData

Code: [Select]
var rowData = myGrid.pqGrid( "getRowData", {rowIndxPage: 2} );
rowData[ dataIndx of checkbox ] = value;

And refresh the grid after setting checkbox values:

Code: [Select]
myGrid.pqGrid( "refresh" );
Title: Re: How to set checkboxes outside the viewport when using virtualX/virtualY?
Post by: omeroon on May 24, 2023, 02:07:33 am
Awesome! I will give this a try.
Title: Re: How to set checkboxes outside the viewport when using virtualX/virtualY?
Post by: omeroon on May 26, 2023, 06:28:21 pm
Worked perfectly!!!

To help somebody else here is what I did: using
Code: [Select]
myGrid.pqGrid( "getColModel" ) I extracted the names of the columns and the values of cb.check and put this in an array.

So something like:
Code: [Select]
colModelArray["colA" => 18, "colB" => 24, "colC" => 33]
Using the code of Paramvir I can now get the rowData of my selection even if the fields are outside the viewport, and I then alter the values based on the dataIndx which is the same as the key of the colModelArray.
Title: Re: How to set checkboxes outside the viewport when using virtualX/virtualY?
Post by: omeroon on May 29, 2023, 09:02:44 pm
@paramvir: is there a way to add these changes to the history as well so I can get undo/redo to work?
Title: Re: How to set checkboxes outside the viewport when using virtualX/virtualY?
Post by: omeroon on June 12, 2023, 02:24:13 pm
Anyone? Would be nice to get the undo/redo options working.