Author Topic: Editable Checkbox in row when groupModel is enabled. v5.3 TypeError: n is undef  (Read 3583 times)

mcburley

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 5
    • View Profile
I have simple checkbox, when groupModel is enabled it does register the "check" and throws a TypeError: n is undefined. References the onBeforeCheck function in the source. It does register the uncheck with a false. I added a checkbox column to the Row Grouping demo, same issue.
Thanks in advance.


    $(function () {
        var colM = [
            { title: "ShipCountry", width: 120, dataIndx: "ShipCountry" },
            { title: "Customer Name", width: 130, dataIndx: "ContactName" },
                             {
                           title: "Paid",
                           width: 220,                         
                           dataIndx: "Paid",
                           type: 'checkbox',
                           cbId: 'chk',
                           useLabel: true
                        }         ,
                        //column to store checkbox state of ProductName.
                        {
                           dataIndx: 'chk',
                           dataType: 'bool',
                           cb: { header: true },
                           hidden: false,
                           editable: function(ui){                           
                              //to make checkboxes editable selectively.
                              return true;
                           }
                        },
            { title: "Freight", width: 120, format: '$##,###.00',
                summary: {
                    type: "sum"
                },
                dataType: "float", dataIndx: "Freight"
            },
            { title: "Shipping Via", width: 130, dataIndx: "ShipVia" },
          { title: "Shipped Date", width: 100, dataIndx: "ShippedDate", dataType: "date" },
            { title: "Shipping Address", width: 220, dataIndx: "ShipAddress" },
            { title: "Shipping City", width: 130, dataIndx: "ShipCity" }
      ];
        var dataModel = {
            location: "remote",
            dataType: "JSON",
            method: "GET",
            url: "/Content/orders.json"
            //url: "/pro/orders/get",//for ASP.NET
            //url: "orders.php",//for PHP
         //,getData: function(data) {
         //console.log(data);
         //   return data;
         //}
        };
        var groupModel = {
            on: true,
            summaryInTitleRow: 'all', //to display summary in the title row.
            dataIndx: ['ShipCountry', 'ContactName'],
            //showSummary: [true], //to display summary at end of every group.           
            title: [
                "{0} ({1})",
                "{0} - {1}"
            ]
        };
        var obj = {
            height: 500,
            toolbar: {
                items: [{
                    type: 'button',
                    label: "Toggle grouping",
                    listener: function () {
                        this.Group().option({
                            on: !this.option('groupModel.on')
                        });
                    }
                }]
            },
            dataModel: dataModel,
            scrollModel: { autoFit: true },
            colModel: colM,
            numberCell: { show: false },           
            selectionModel: { type: 'cell' },
            groupModel: groupModel,
            showTitle: false,
            resizable: true,
            menuIcon: true,
            hwrap: false,
            wrap: false
        };
        pq.grid("#grid_group_rows", obj);

    });

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Use of checkbox is different in row grouping and treegrid than in a normal grid.

Please check this example for use of checkbox in row grouping:

https://paramquery.com/pro/demos/group_rows_checkbox

mcburley

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 5
    • View Profile
Hopefully I'm not missing something obvious, but using the example you noted: For example you group by ShipCountry (no group check boxes needed) and you have a checkbox on the Paid column to mark and post the item as paid. The example code below does not capture true and throws the TypeError.
My apologies in advance if I'm not understanding the usage of a checkbox in a grouped grid.


$(function () {       
        var colM = [           
            { title: "Customer Name", width: 130, dataIndx: "ContactName" },
                                      {
                           title: "Paid",
                           width: 220,                         
                           dataIndx: "Paid",
                           type: 'checkbox',
                           cbId: 'chk',
                           useLabel: true
                        }         ,
                        //column to store checkbox state of ProductName.
                        {
                           dataIndx: 'chk',
                           dataType: 'bool',
                           cb: { header: true },
                           hidden: false,
                           editable: function(ui){                           
                              //to make checkboxes editable selectively.
                              return true;
                           }
                  },   
            { title: "ShipCountry", width: 120, dataIndx: "ShipCountry" },           
            { title: "Freight", width: 120, format: '$##,###.00',
                summary: {
                    type: "sum"
                },
                dataType: "float", dataIndx: "Freight"
            },
            { title: "Shipping Via", width: 130, dataIndx: "ShipVia" },
          { title: "Shipped Date", width: 100, dataIndx: "ShippedDate", dataType: "date" },
            { width: 100, dataIndx: "OrderID" },
            { title: "Shipping City", width: 130, dataIndx: "ShipCity" }
      ];
        var dataModel = {
            location: "remote",
            dataType: "JSON",
            method: "GET",
            url: "/Content/orders.json"
            //url: "/pro/orders/get",//for ASP.NET
            //url: "orders.php",//for PHP
        };
        var groupModel = {
            checkbox: false,
            checkboxHead: false,           
            on: true,
            dataIndx: ['ShipCountry'],                       
            menuItems: ['grandSummary'],           
            summaryInTitleRow: 'all',
            titleInFirstCol: true,
            fixCols: false,
            indent: 20,
            collapsed: [false, true],
            title: [
                "{0} ({1})",
                "{0} - {1}"
            ],
            useLabel: true
        };
        var obj = {
            height: 500,
            toolbar: {
                items: [
                {
                    type: 'button',
                    label: "Toggle grouping",
                    listener: function () {
                        var on = this.option('groupModel.on');                                               
                        //toggle grouping.
                        this.Group().option({ on: !on });
                    }
                },
                {
                    type: 'checkbox',
                    label: 'bind selections',                               
                    listener: function(evt){                       
                        this.Group().unCheckAll();//first clear all.

                        this.Group().option({select: evt.target.checked});                       
                    }
                },               
                {
                    type: 'button',
                    label: "Get checked",
                    listener: function () {
                        var selected = this.Group().getCheckedNodes().map(function(rd) {
                          return rd.OrderID;
                        })
                        alert( selected );
                    }
                }
                ]
            },
            dataModel: dataModel,
            scrollModel: { autoFit: true },
            colModel: colM,
            numberCell: { show: false },
            menuIcon: true,                       
            groupModel: groupModel,
            showTitle: false,           
            hwrap: false,
            wrap: false
        };
        pq.grid("#grid_group_rows", obj);

    });

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
The checkbox columns are used for row selections or displaying / editing true, false values of a column.

I see you mean to use the checkbox column in row grouping for latter purpose.

I also see the error when it's used that way, I'm moving it to bug report, fix would be available in next version ( ETA : 15 Sept)

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
This is fixed in v5.4.0