ParamQuery grid support forum

General Category => ParamQuery Pro Evaluation Support => Topic started by: rickpqu on August 15, 2015, 01:29:39 am

Title: How to do single-column sort?
Post by: rickpqu 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?
Title: Re: How to do single-column sort?
Post by: paramvir 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
Title: Re: How to do single-column sort?
Post by: rickpqu 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);
};