Author Topic: Set summary column to Sum or Empty based on column grouping in saved gridState  (Read 267 times)

mikep

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 163
    • View Profile
I'm able to change the summary type when the grouping column changes using the groupChange below.

                    groupChange: function () {
                        var GMDI = this.option('groupModel.dataIndx');
                        if (GMDI.indexOf('res') == 0 ) {
                            this.getColumn({ dataIndx: '% Allocate' }).summary = { type: 'sum' };
                        }
                        else {
                            this.getColumn({ dataIndx: '% Allocate' }).summary = {};
                        }
                    }

How would i implement similar logic after I apply a grid state: $gridMain.pqGrid("loadState", { state: result }, false);
//now set the summary type for columns, based on grouping in the state



paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
you can do either of these:

1) use groupOption event instead of groupChange event. it's called even during loadState.

or

2) Change the callback to a named function ( e.g., someFn ) and assign it to groupChange event and call it manually after loadState.

Code: [Select]
groupChange: someFn

Code: [Select]
//call it after loadState.
someFn.call( grid ); //where grid is pqgrid instance.