ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: TeeJT on July 18, 2017, 03:03:22 pm
-
I used your standard demo for grouped rows for Pro version at https://paramquery.com/pro/demos/group_rows
I just removed all groupings and added "Shipping Date" as only group.
The result is that the shipping dates are not sorted. Do I need to sort the grouped column?
I expected my empty or null date to be on top.
-
Grouping and sorting are made independent of each other since v3.4.0, so yes you have to sort the column to get it sorted.
-
If I want the previous behavior, I would need to remove this sort if found and introduce it at the head.
Similarly for the second grouping, I would need to remove this sort if found and introduce it as the second sort. etc.
-
I tried to add this code at refreshHeader event but it does not sort correctly.
// Get Group Model
var gModel = $(gridDiv).pqGrid( "option", "groupModel");
// Get Sort List
var sortModel = $(gridDiv).pqGrid( "option", "sortModel");
var sortList = sortModel.sorter;
var groupList = gModel.dataIndx;
// add the grouped columns to the front of sort list
for (var i=groupList.length-1; i>=0; i--) {
var grpIdx = groupList[i];
// remove grpIdx from sortList
sortList = $.grep(sortList, function (el) { return el.dataIndx!= grpIdx; });
// add grpIdx to front of sortList
sortList.splice(0,0,{dataIndx:grpIdx, dir: "up"})
}
// Apply new sortList
sortModel.sorter = sortList;
$(gridDiv).pqGrid( "option", "sortModel", sortModel );
-
groupChange and complete events can be used to sort the groupby columns whenever there is change in grouping.
groupChange: function(){
var GM = this.option("groupModel"), sorter = [];
GM.dataIndx.forEach(function(di){
sorter.push({dataIndx: di, dir: 'up' });
});
this.sort( {sorter: sorter});
},
complete: function(){
this.option('groupChange').call(this);
},