Author Topic: i cant implement group_row_hidden  (Read 490 times)

arbyter

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 35
    • View Profile
i cant implement group_row_hidden
« on: September 30, 2021, 08:14:19 pm »
hi
i try to implement group_row_hidden in my projects. But i encounter strange results.. i am sure, to make some mistake, but after severel days of trying i am going to ask you.
As an approach, i set up a minimalistic example based on https://paramquery.com/pro/demos77/grid_json , and the result is similar to what i get in my project.
I altered this example with the grouping stuff like so: (paste it and start it, you  will see what i mean)
$(function () {
   function hideCol(col, hide){
            col.hidden = hide;
            col.menuInDisable = hide;           
        }
        var data = [
            { rank: 1, company: 'Exxon Mobil', revenues: 339938.0, profits: 36130.0 },
            { rank: 1, company: 'Wal-Mart Stores', revenues: 315654.0, profits: 11231.0 },
            { rank: 1, company: 'Royal Dutch Shell', revenues: 306731.0, profits: 25311.0 },
            { rank: 2, company: 'BP', revenues: 267600.0, profits: 22341.0 },
            { rank: 2, company: 'General Motors', revenues: 192604.0, profits: -10567.0 },
            { rank: 2, company: 'Chevron', revenues: 189481.0, profits: 14099.0 },
            { rank: 2, company: 'DaimlerChrysler', revenues: 186106.3, profits: 3536.3 },
            { rank: 2, company: 'Toyota Motor', revenues: 185805.0, profits: 12119.6 },
            { rank: 3, company: 'Ford Motor', revenues: 177210.0, profits: 2024.0 },
            { rank: 10, company: 'ConocoPhillips', revenues: 166683.0, profits: 13529.0 },
            { rank: 11, company: 'General Electric', revenues: 157153.0, profits: 16353.0 },
            { rank: 12, company: 'Total', revenues: 152360.7, profits: 15250.0 },
            { rank: 13, company: 'ING Group', revenues: 138235.3, profits: 8958.9 },
            { rank: 14, company: 'Citigroup', revenues: 131045.0, profits: 24589.0 },
            { rank: 15, company: 'AXA', revenues: 129839.2, profits: 5186.5 },
            { rank: 16, company: 'Allianz', revenues: 121406.0, profits: 5442.4 },
            { rank: 17, company: 'Volkswagen', revenues: 118376.6, profits: 1391.7 },
            { rank: 18, company: 'Fortis', revenues: 112351.4, profits: 4896.3 },
            { rank: 19, company: 'Crédit Agricole', revenues: 110764.6, profits: 7434.3 },
            { rank: 20, company: 'American Intl. Group', revenues: 108905.0, profits: 10477.0 }
        ];
      var groupModel = {
            on: true,
            headerMenu: false,
            indent: 20,
            dataIndx: ['rank'],
            //summaryInTitleRow: '',
            //titleIndx: 'grp',
            titleInFirstCol: true,
            showSummary: [false], //to display summary at end of every group.
            collapsed: [true],
            summaryEdit: false
        };
        var obj = {
            width: "80%",
            height: 400,
            resizable: true,
            title: "Grid From JSON",
            showBottom: false,
            scrollModel: { autoFit: true },
            dataModel: { data: data },
         groupModel:groupModel,
         groupChange: function () {
                //make a copy of array.
                var di_old = Object.assign([], groupModel.dataIndx);
                return function () {
                    //make a copy of array.
                    var di_new = Object.assign([], this.option('groupModel.dataIndx')),
                        grid = this;

                    //show prev columns.
                    di_old.forEach(function(di){
                        var col = grid.getColumn({dataIndx: di});
                        hideCol(col, false);
                    });

                    //hide new columns.
                    di_new.forEach(function(di){
                        var col = grid.getColumn({dataIndx: di});
                        hideCol(col, true);
                    });   

                    di_old = di_new;                   

                    this.refreshCM();
                };
            }(),
            create: function(){               
                groupModel.dataIndx.forEach(function(di){
               hideCol( this.getColumn({dataIndx: di}), true);
                }, this);
                this.refreshCM();
            },
        };
        $("#grid_json").pqGrid(obj);
    });   
   

arbyter

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: i cant implement group_row_hidden
« Reply #1 on: October 01, 2021, 01:37:55 pm »
today i found out: after the first start, grouping behaves strange, but if you delete the group butten (rank) and drag it again to the grouping section, then grouping behaves like expected.


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 5339
    • View Profile
Re: i cant implement group_row_hidden
« Reply #2 on: October 01, 2021, 03:42:44 pm »
[ Only Pro members may read this post. ]