Author Topic: How to do single-column sort?  (Read 3354 times)

rickpqu

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 26
    • View Profile
How to do single-column sort?
« on: August 15, 2015, 01:29:39 am »
Hi, as I switched from ParamQuery Pro 2.4 to ParamQuery Pro 3, the default sorting mode seems to have changed from single-column (with multiple column sorting possible by shift-click) to multiple-column sorting. Is there a way to implement the behavior of clicking a header -> single column sorting and shift-clicking a header -> multiple column sorting?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6260
    • View Profile
Re: How to do single-column sort?
« Reply #1 on: August 18, 2015, 10:56:01 am »
That's easy in version 3.

In headerCellClick event, check event.shiftKey and update the option sortModel.single accordingly.

http://paramquery.com/pro/api#event-headerCellClick

http://paramquery.com/pro/api#option-sortModel
« Last Edit: August 18, 2015, 11:05:02 am by paramquery »

rickpqu

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: How to do single-column sort?
« Reply #2 on: August 18, 2015, 08:39:58 pm »
Thanks. That solved the problem. For posterity, I used something like the code below.

gridObj.headerCellClick = function (evt, ui) {
   var sortModel = $grid.pqGrid('option', 'sortModel');
   if (evt.shiftKey) {
      sortModel.single = false;
   } else {
      sortModel.single = true;
   }
   $grid.pqGrid('option', 'sortModel', sortModel);
};