ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: nzxgq0 on September 01, 2021, 10:38:04 am

Title: Sort by grp column with Group Model not working at normal mode and pivot mode
Post by: nzxgq0 on September 01, 2021, 10:38:04 am
Hello there,

we want to sort the grp column by default.
Code: [Select]
groupModel: {
            checkbox: true,
            checkboxHead: true,
            on: true,
            pivot: false, //pivotMode
            summaryInTitleRow: 'all', //to display summary in the title row.
            header: false, //hide grouping toolbar.
            grandSummary: true,
            titleInFirstCol: true,
            titleIndx: 'grp',
            fixCols: false,
            dataIndx: ['Item'],
            groupCols: [], //grouping along column axis.
            collapsed: [true, true],
            agg: {
                Count: "sum"
            },
            showSummary: [false], //to display summary at end of every group.
            title: [
                "{0} ({1})",
                "{0} - {1}"
            ],
            summaryTitle: {
                sum: ""
            }        },
sortModel: {

            sorter: [{ dataIndx: 'grp', dir: 'up' }],
            space: true,
            ignoreCase: true,
            multiKey: null,
            single: false
        }


However it is not working. It shows the small triangle but actually it is not sorting.



we also want to keep the group sorted at the pivot mode. Still no luck.
If we choose another column other than the "grp" column - such as the Item column in the example, it works.


Any idea? thanks.
Title: Re: Sort by grp column with Group Model not working at normal mode and pivot mode
Post by: nzxgq0 on September 01, 2021, 02:13:35 pm
Please check the image attached
Title: Re: Sort by grp column with Group Model not working at normal mode and pivot mode
Post by: paramvir on September 02, 2021, 03:02:53 am
Which version of pqgrid you are using? Please try calling sort method in complete event.

https://paramquery.com/pro/api#method-sort

https://paramquery.com/pro/api#event-complete
Title: Re: Sort by grp column with Group Model not working at normal mode and pivot mode
Post by: nzxgq0 on September 02, 2021, 09:36:08 am
Thanks. I am using Pro 8.0.1.

Your approach by sorting the data inside the complete event is working at the first page load.

When updating the group by adding/removing columns into/from the row group, the sorting is gone.
Any idea to ensure the sort of the group?

Note the screenshots are not well ordered. See the FirstLoad, 2.AddStageToGroup then 3.SecondLevelNotSorted.
By the way, I tried "this.sort()" inside the groupOption event, but it didn't help.
Title: Re: Sort by grp column with Group Model not working at normal mode and pivot mode
Post by: paramvir on September 02, 2021, 05:47:54 pm
Please use groupChange event instead of groupOption event.

Code: [Select]
groupChange: function(){
  this.sort();
}

Try this if the above doesn't work
Code: [Select]
groupChange: function(){
  var grid = this;
  setTimeout(function(){
    grid.sort();
  }); 
}

Title: Re: Sort by grp column with Group Model not working at normal mode and pivot mode
Post by: nzxgq0 on September 02, 2021, 09:32:20 pm
Please use groupChange event instead of groupOption event.

Code: [Select]
groupChange: function(){
  this.sort();
}

Try this if the above doesn't work
Code: [Select]
groupChange: function(){
  var grid = this;
  setTimeout(function(){
    grid.sort();
  }); 
}
Hi paramvir, it looks the groupChange event is not fired when dragging and dropping a column on the toolPanel but the groupOption is.
I tried your setTimeout method in groupOption and it worked. Thanks.