Author Topic: how to get selected rows when some are hidden?  (Read 8819 times)

argo

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 33
    • View Profile
how to get selected rows when some are hidden?
« on: August 12, 2013, 09:22:42 pm »
My grid is created from an array of objects (json). I'm adding a bulk-edit functionality based on the selected rows. In order to commit changes based on the selected rows, I need the primary key of each selected row. This primary key is also displayed as a column in the grid. I can determine which rows are selected using:
myGrid.pqGrid( "selection", { type:'row', method:'getSelection' } )

However I can't find a way to select the primary key directly from the source data. I tried using the "getRow" method on each selected row and parsing the returned TR to extract the key value, but it doesn't appear that you can select rows that are hidden (i.e. if some of the selected rows are on a previous page). This can happen if someone clicks a row on page 1, then goes to page 2 and shift-clicks a row. In this case, the "selection" method may say that 5 rows are selected, but the "getRow" method can only get the rows on the current page, not the ones on a previous page. Maybe I'm going about this wrong.

Is there a way to go directly to the json data objects that correspond to the selected rows? If not, is there a way to turn off multi-selection across multiple pages?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: how to get selected rows when some are hidden?
« Reply #1 on: August 12, 2013, 11:02:21 pm »
rowIndx is the index of row in dataModel.data

1) var arr = myGrid.pqGrid( "selection", { type:'row', method:'getSelection' } ) provides the rowIndices of the selected rows.

2) You can get the JSON data for the selected rows from dataModel.data

var data = dataModel.data;

for (var i=0; i< arr.length;i++){
  var rowIndx = arr[ i ];
  var jsonobj = data[ rowIndx ];
}

I hope it gives you the idea.

« Last Edit: August 12, 2013, 11:13:52 pm by paramquery »

argo

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: how to get selected rows when some are hidden?
« Reply #2 on: August 12, 2013, 11:47:09 pm »
Thanks so much, it is exactly what I needed to know.