Author Topic: Sort by grp column with Group Model not working at normal mode and pivot mode  (Read 2023 times)

nzxgq0

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 25
    • View Profile
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.

nzxgq0

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 25
    • View Profile
Please check the image attached

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
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

nzxgq0

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 25
    • View Profile
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.
« Last Edit: September 02, 2021, 09:58:38 am by nzxgq0 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
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();
  }); 
}


nzxgq0

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 25
    • View Profile
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.