Author Topic: Get currently selected single row  (Read 3169 times)

seb

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 10
    • View Profile
Get currently selected single row
« on: November 15, 2018, 09:05:35 pm »
Hi,

I'm having real trouble upgrading my code from the free version, to the pro version. I'm stuck on trying to get the currently selected row in a grid. This is my code that used to work with the free version of PQGrid:

Code: [Select]
var d = $grid.pqGrid("selection", {type:'row', method:'getSelection'})[0].rowData;
This no longer works, and seems that the selection array is empty, even though a row is selected. Here is how I initialised the grid:

Code: [Select]
$grid = $("#grid").pqGrid({
colModel: [
{ title: "Client Name", width: 383, dataType: "string", dataIndx: "client_name" }
],
dataModel: {
location: "remote",
dataType: "json",
method: "POST",
postData: getPostData(),
url: "/api/accounts/get_clients.php",
getData: function(d) {
return { data: d.data };
}
},
scrollModel: { autoFit: true },
height: 424,
showTop: false,
showBottom: false,
resizable: false,
editable: false,
numberCell: { show: false },
selectionModel: { type: 'row', mode: 'single' },
hoverMode: 'row'
});

How do I get the currently selected row? (only full, single rows are what are allowed).

Thank you! :)

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6298
    • View Profile
Re: Get currently selected single row
« Reply #1 on: November 15, 2018, 09:16:25 pm »
differences between free and Pro version for row selections are mentioned in this upgrade guide:

https://paramquery.com/pro/upgrade/Index40

API: https://paramquery.com/pro/api#method-SelectRow

Code: [Select]
//Get all row selections
var selectionArray = grid.SelectRow().getSelection();

seb

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Get currently selected single row
« Reply #2 on: November 15, 2018, 09:29:27 pm »
Thank you for the clarification. For reference, this is now what works for me to get the currently selected row:

Code: [Select]
var d = $grid.pqGrid("SelectRow").getSelection()[0].rowData;