Author Topic: pq_rowselect not working  (Read 3966 times)

argo

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 33
    • View Profile
pq_rowselect not working
« on: June 03, 2014, 07:10:24 pm »
I'm building a "Select All" button for the grid that is meant to select all rows in the entire data model, regardless of how many are actually displayed on the page. I originally built the function using the selection method, but that turns out to be very slow when there are thousands of rows. From the post I read below, the selection method isn't designed for that. The solution in the post below is to use the pq_rowselect property:
http://paramquery.com/forum/index.php?topic=448.msg2888#msg2888

I've implemented as the post indicates but when I refresh the grid there are no rows selected. The grid remains unchanged. And if I check the selection size afterward the # of rows returned selected is zero. Here is the code I'm using:

Code: [Select]
function selectAllQuestions() {
var DM = $qgrid.pqGrid("option","dataModel");
if (DM.data.length > 0) {
for (var i=0;i<DM.data.length;i++) {
var rowData = DM.data[i];
rowData.pq_rowselect = true;

}
$qgrid.pqGrid("refresh");
}
}

Any ideas?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: pq_rowselect not working
« Reply #1 on: June 03, 2014, 10:16:10 pm »
It's selectedRow instead of pq_rowselect in basic version.

argo

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: pq_rowselect not working
« Reply #2 on: June 03, 2014, 10:30:31 pm »
Thanks, didn't realize that was a pro-only property. However, using the selectedRow property doesn't appear to actually update the selection. It visually updates the grid to appear as if it is selected, but if you call

Code: [Select]
$qgrid.pqGrid("selection",{type:'row', method:'getSelection'});
The array length is zero even though all the rows now visually look as if they are selected.

What's even more odd, once all the rows have their selectedRow property set to true, from that point forward clicking any row doesn't visually update the grid. Every row in the grid visually appears to be selected permanently (until page refresh). Even calling the pqgrid removeAll selection method doesn't fix it.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6263
    • View Profile
Re: pq_rowselect not working
« Reply #3 on: June 07, 2014, 09:17:13 am »
Sorry for late reply.

It's also required to refresh the selection ( in basic version only ) after updating the selectedRow property. refresh should be done after the loop is complete.

                   $grid.pqGrid("selection", {
                       method: 'refresh',
                       type: 'row'
                   });


http://jsfiddle.net/LAgZx/330/
« Last Edit: June 07, 2014, 11:08:12 am by paramquery »