Author Topic: Does the demo not support grouping?  (Read 4369 times)

dreams

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 21
    • View Profile
Does the demo not support grouping?
« on: February 25, 2020, 08:59:23 am »
Does the demo not support grouping?
I just downloaded the unregistered version.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6255
    • View Profile
Re: Does the demo not support grouping?
« Reply #1 on: February 25, 2020, 09:12:10 am »

dreams

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Does the demo not support grouping?
« Reply #2 on: February 25, 2020, 11:51:27 am »
I followed this example, but I still got it wrong, I don't know where I didn't get it right, I'll try again.
error info:uncaught exception: use groupOption() to set groupModel options.
_setOption http://localhost:1981/Content/paramquery-pro/pqgrid.min.js:10
    jQuery 7

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6255
    • View Profile
Re: Does the demo not support grouping?
« Reply #3 on: February 25, 2020, 02:51:36 pm »
The error means it.

Please use Group().option() to set groupModel options in run time instead of grid.option( 'groupModel', ....)

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

Example: https://paramquery.com/pro/demos/group_rows

Please let me know if you need more help.

dreams

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Does the demo not support grouping?
« Reply #4 on: February 26, 2020, 07:47:23 am »
Thank you very much, the problem has been solved!I am sorry that I am also a novice, ready to report to the leadership, buy the enterprise version ~!

dreams

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 21
    • View Profile
Hello!Is advisory "groupModel" last time I use, now realize the basic functions, but when the first load data is normal, data updates to reload it again "the error info: uncaught exception: use groupOption () to set groupModel options." mistakes, I use is "$(" # gridtable_KL"). PqGrid (" refreshDataAndView ");"That is a wrong way?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6255
    • View Profile
Re: Does the demo not support grouping?
« Reply #6 on: February 27, 2020, 10:43:46 am »
refreshDataAndView doesn't cause this error. Please share a jsfiddle.

dreams

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Does the demo not support grouping?
« Reply #7 on: February 27, 2020, 12:30:26 pm »
        // 初始化列表
        initGird: function () {
            alert(JSON.stringify(gridtable_KL_data));
            var data = gridtable_KL_data;

                //array of columns.
            var colModel = [
                {
                    title: "部门", //title of column.
                    align: "center", //垂直居中
                    hvalign: "center",//水平居中    "top", "center" and "bottom".
                    width:120, //initial width of column
                    dataType: "integer", //data type of column
                    dataIndx: "CCATCNAME", //should match one of the keys in row data.
                    styleHead: { 'font-weight': 'bold' }  //应用样式

                },
                    {
                        title: "大类", //title of column.
                        align: "center", //垂直居中
                        menuInDisable: true,//不能隐藏
                        hvalign: "center",//水平居中    "top", "center" and "bottom".
                        width: 100, //initial width of column
                        dataType: "integer", //data type of column
                        dataIndx: "JMDMKTNAME", //should match one of the keys in row data.
                        styleHead: { 'font-weight': 'bold' }  //应用样式

                    },
                    {
                        title: "负责人",
                        hdenid: true,
                        width: 100,
                        menuInDisable: true,//不能隐藏
                        dataType: "string",
                        hvalign: "center",
                        align: "center",
                        dataIndx: "F_MANAGER",
                        styleHead: { 'font-weight': 'bold' }  //应用样式
                    },
                    {
                        title: "月累计客流(人次)", styleHead: { 'font-weight': 'bold' }, width: 300, align: "center", colModel: [
                            {
                                title: "本期",
                                width: 60,
                                dataType: "float",
                                align: "right",
                                dataIndx: "SMDKLL",
                                //格式化
                                //format: function (val) {
                                //    return val;
                                //},
                                summary: {
                                    type: "sum"
                                }
                                //format: "#####"
                            },
                            {
                                title: "同期",
                                width: 60,
                                dataType: "float",
                                align: "right",
                                dataIndx: "SMDKLL2",
                                summary: {
                                    type: "sum"
                                }

                            },
                            {
                                title: "差异",
                                width: 60,
                                dataType: "float",
                                align: "right",
                                dataIndx: "KLCY",
                                format: function (val) {
                                    if (val <= 0) {
                                        return redblack + val + endblack;
                                    } else {
                                        return black + '+' + val + endblack;
                                    }

                                },
                                summary: {
                                    type: "sum"
                                }

                            }]
                    },
                    {title: "占店比", styleHead: { 'font-weight': 'bold' }, width: 300, align: "center", colModel: [
                            {
                                title: "本店",
                                width: 60,
                                dataType: "float",
                                align: "right",
                                dataIndx: "profits"
                            }
                            ,
                            {
                                title: "标杆",
                                width: 60,
                                dataType: "float",
                                align: "right",
                                dataIndx: "profits"
                            }
                        ]
                    },
                    {
                        title: "客单价(元)", styleHead: { 'font-weight': 'bold' }, width: 300, align: "center", colModel: [
                            {
                                title: "本期",
                                width: 60,
                                dataType: "float",
                                align: "right",
                                dataIndx: "KDJ",
                            summary: {
                                type: "avg"
                            }
                                //format: function (val) {
                                //    return val.toFixed(2);
                                //}

                            },
                            {
                                title: "同期",
                                width: 60,
                                dataType: "float",
                                align: "right",
                                dataIndx: "KDJ2",
                                summary: {
                                    type: "avg"
                                }
                                //format: function (val) {
                                //    return val.toFixed(2);
                                //}

                            } ,
                            {
                                title: "差异",
                                width: 60,
                                dataType: "float",
                                align: "right",
                                dataIndx: "KDJCY",
                                format: function (val) {
                                    if (val <= 0) {
                                        return redblack + Tnumber(val * 10000) + endblack;
                                    } else {
                                        return black + '+' + Tnumber(val * 10000) + endblack;
                                    }

                                },
                                summary: {
                                    type: "avg"
                                }

                            },
                            {
                                title: "增幅",
                                hdenid: true,
                                width: 60,
                                //menuInDisable: true,//不能隐藏
                                dataType: "string",
                                hvalign: "center",
                                align: "right",
                                //dataIndx: "company",
                                //styleHead: { 'font-weight': 'bold' }  //应用样式

                            }]
                    },
                    {
                        title: "月累计销售(万元)", styleHead: { 'font-weight': 'bold' }, width: 300, align: "center", colModel: [
                            {
                                title: "本期",
                                width: 60,
                                dataType: "float",
                                align: "right",
                                dataIndx: "AXSSR",
                                format: function (val) {
                                    return Tnumber(val);
                                }
                            },
                            {
                                title: "同期",
                                width: 60,
                                dataType: "float",
                                align: "right",
                                dataIndx: "BXSSR",
                                format: function (val) {
                                    return Tnumber(val);
                                }

                            },
                            {
                                title: "差异",
                                width: 60,
                                dataType: "float",
                                align: "right",
                                dataIndx: "LJXSCY",
                                format: function (val) {
                                    if (val >= 0) {
                                        return black + Tnumber(val) + endblack;
                                    } else {
                                        return redblack + Tnumber(val) + endblack;
                                    }

                                }

                            },
                            {
                                title: "增幅",
                                hdenid: true,
                                width: 60,
                                //menuInDisable: true,//不能隐藏
                                dataType: "string",
                                hvalign: "center",
                                align: "right",
                                dataIndx: "LJXSZZL",
                                format: function (val) {
                                    if (val >= 0) {
                                        return black + Tnumber(val * 10000) + '%' + endblack;
                                    } else {
                                        return redblack + Tnumber(val * 10000) + '%' + endblack;
                                    }

                                }
                                //dataIndx: "company",
                                // styleHead: { 'font-weight': 'bold' }  //应用样式

                            }]
                    },
                    {
                        title: "占店比", styleHead: { 'font-weight': 'bold' }, width: 300, align: "center", colModel: [
                            {
                                title: "本店",
                                width: 60,
                                dataType: "float",
                                align: "right",
                                dataIndx: "XSZB"

                            },
                            {
                                title: "标杆",
                                hdenid: true,
                                width: 60,
                                //menuInDisable: true,//不能隐藏
                                dataType: "string",
                                hvalign: "center",
                                align: "right",
                                dataIndx: "BGXSZB",
                               // styleHead: { 'font-weight': 'bold' }  //应用样式

                            }]
                    }

            ];
            var groupModel = {
                on: true,
                //checkbox: true, checkboxHead: true, cascade: true,
                titleInFirstCol: true,
                fixCols: false, indent: 18,
                pivot: false,
                agg: {
                    'AXSSR': 'sum',
                    'BXSSR': 'sum',
                    'LJXSCY': 'sum',
                  //  'LJXSCY': 'sum',
                },
                groupCols: ['qtr'],
                collapsed: [false, false, false, false],
                summaryInTitleRow: 'all', //to display summary in the title row.
                dataIndx: ['CCATCNAME'],
                //showSummary: [true], //to display summary at end of every group.           
                title: [
                    "{0} ({1})"
                ]
            };

                //main object to be passed to pqGrid constructor.   
                var obj = {
                    toolbar: {
                        items: [{
                            type: 'button',
                            label: "Toggle grouping",
                            listener: function () {
                                this.Group().option({
                                    on: !this.option('groupModel.on')
                                });
                            }
                        }]
                    },
                    //分组不显示数据前的标题
                    summaryTitle: {
                        avg: "",
                        count: '',
                        max: "",
                        min: "",
                        stdev: "",
                        stdevp: "",
                        sum: ""
                    },
 

                   flex: {one: true},
 

                    menuIcon: true,
                    menuUI: {
                        tabs: ['hideCols']
                    },

                    dataModel: { data: data },
 
                    colModel: colModel,
                    formulas: [
                        ["KLCY", function (rd) {
                            return rd.SMDKLL - rd.SMDKLL2;
                        }],
                        ["KDJCY", function (rd) {
                            return rd.KDJ - rd.KDJ2;
                        }],
                        ["LJXSCY", function (rd) {
                            return rd.AXSSR - rd.BXSSR;
                        }]
                    ],
                    //合计
                    summaryData: [
                        { CCATCNAME: '合计', summaryRow: true, pq_fn: { SMDKLL: 'sum(D:D)/2', SMDKLL2: 'sum(E:E)/2', KLCY: 'sum(F:F)/2', AXSSR: 'sum(M:M)/2', BXSSR: 'sum(N:N)/2', LJXSCY: 'sum(M:M)/2-sum(N:N)/2', LJXSZZL: 'round((sum(M:M)/2-sum(N:N)/2)/sum(N:N)/2,4)*100'} }
 
                    ],
                    freezeCols: 2,
                    groupModel: groupModel,
 
                    title: "客单客流"
 
                };

            //$("#gridtable_KL").pqGrid(obj);
            alert(JSON.stringify(obj.groupModel));

            gridtable_KL = pq.grid("#gridtable_KL", obj);
            var groupModel = gridtable_KL.option("groupModel");
 
           $("#gridtable_KL").pqGrid("refreshDataAndView");

        },

dreams

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Does the demo not support grouping?
« Reply #8 on: February 27, 2020, 12:33:30 pm »
Is there a problem with that?

dreams

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Does the demo not support grouping?
« Reply #9 on: February 27, 2020, 12:37:32 pm »
        search: function (param) {

            var dtemp1 = $("#datesearchB").val();
            var dtemp2 = $("#datesearchT").val();

            var tempdate = dtemp1.split('~');
            startTime = tempdate[0];
            endTime = tempdate[1];

            var tempdatet = dtemp2.split('~');
            startTimeT = tempdatet[0];
            endTimeT = tempdatet[1];
            //alert(ProcName);
                param = param || {};
                param.StartTime = startTime;
                param.EndTime = endTime;
                param.StartTimeT = startTimeT;
                param.EndTimeT = endTimeT;
                //alert(mkts);
                param.Mkts = mkts;
                param.Cats = '';
                param.big_qy = '';
                param.ProcName = ProcName;
            //$('#gridtable').jfGridSet('reload', { queryJson: JSON.stringify(param) });
           // alert(JSON.stringify(param));
            var pagination = {};
            pagination.rows = 10000;
            pagination.page = 1;
            pagination.sidx = '';
            pagination.sord = 'ASC';
            pagination.records = 0;
            pagination.total = 0;
            pagination.costtime = 0;
           // alert(JSON.stringify(pagination));

            //{ "rows": 10000, "page": 1, "sidx": "", "sord": "ASC", "records": 0, "total": 0, "costtime": 0 }
                //alert("1234567");

                learun.loading(true, '正在获取数据');
            //learun.httpAsync('GET', url, param, function (data) {
            learun.httpAsync('GET', top.$.rootUrl + '/JH_NewReport/JH_NewRoprt_Sale/GetPageList_Sales_GZ_PQ', { pagination: JSON.stringify(pagination), queryJson: JSON.stringify(param) },
                function (data) {
                    learun.loading(false);
                    var rowdatas = data.rows || [];
                    gridtable_KL_data = rowdatas;
               // alert(JSON.stringify(data.rows));

                    page.initdata();

                   // $("#gridtable_YSDC").pqGrid("refreshDataAndView");
                    $("#report_box").attr("style", "display:block");

                   
                });
           
        },

dreams

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Does the demo not support grouping?
« Reply #10 on: February 27, 2020, 12:43:46 pm »
This is the way I fetch Numbers from the background, one query, one fetch from the background, and then update the ta

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6255
    • View Profile
Re: Does the demo not support grouping?
« Reply #11 on: February 27, 2020, 08:19:58 pm »
Please share a jsfiddle so that it can be checked.