Author Topic: setSelection by criteria other than rowIndx  (Read 2837 times)

ckrosnowski

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 5
    • View Profile
setSelection by criteria other than rowIndx
« on: September 25, 2014, 11:31:33 pm »
hello,

when the grid gets re-sorted, how can I get a listing of the rows within that current state?

let me explain my problem.

I have an external function that links map markers to rows on the grid.
when the map marker is clicked, I call this:

                    $("#gridContainer").pqGrid("setSelection", { rowIndx: this.DisplayNumber, focus: false });
                    // set the row where rowIndx = this.DisplayNumber

it works great, until the user sorts the grid in any way - then the MapMarkers vs rowIndx becomes out of sync.

basically what I need to do is to be able to set the row selection based on the value of a cell within the desired row, so something like this maybe?
                   
                    $("#gridContainer").pqGrid("setSelection", { MapMarker: this.DisplayNumber, focus: false });
                    // set the row where the row's cell 'MapMarker' = this.DisplayNumber


thanks!!!


« Last Edit: September 26, 2014, 12:54:19 am by ckrosnowski »

ckrosnowski

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: setSelection by criteria other than rowIndx
« Reply #1 on: September 25, 2014, 11:34:38 pm »
does this make sense?  I thought I had I solved but I was wrong....
« Last Edit: September 26, 2014, 12:32:44 am by ckrosnowski »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: setSelection by criteria other than rowIndx
« Reply #2 on: September 26, 2014, 12:58:52 am »
Quote
when the grid gets re-sorted, how can I get a listing of the rows within that current state?

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

Quote
I need to do is to be able to set the row selection based on the value of a cell within the desired row
To set selection based upon a cell value, it could be something like this.

Code: [Select]
var $grid = $("#gridContainer"),
      data = $grid.pqGrid( 'option', 'dataModel').data;

for(var i=0; i< data.length; i++){
  var rowData = data[i];
  if ( rowData['MapMarker'] == this.DisplayNumber ){
    $grid.pqGrid("setSelection", { rowIndx: i, focus: false });
    break;
  }
}
« Last Edit: September 26, 2014, 11:56:09 am by paramquery »

ckrosnowski

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: setSelection by criteria other than rowIndx
« Reply #3 on: September 26, 2014, 06:39:48 pm »
I was thinking of this exact logic, just wasn't sure how to get the data from the grid (outside of the grid).
This works exactly how I need it to.
Thanks for the top-notch product / support!