Author Topic: aggregate access different column and checkboxes between state  (Read 3966 times)

lhohman

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 9
    • View Profile
aggregate access different column and checkboxes between state
« on: November 23, 2019, 06:25:23 am »
Greetings,

We are very glad usign your powerful library for our customers, while building this interface
https://jsfiddle.net/thephoenixbird/pfram1v7/113/ we found the following issues.

The requirement is to have the Update column summary to work the following way:
  • If the cell value in the Update column is null, then dont show a zero (0) on the summary cell. I have somehow managed to do this using the agg2.updates custom method
  • If the cell value in the Update column is null, then take the value of the Proposal value into the summary total sum, but keep the cell empty (cant use formulas here), in the provided jsfiddle you can see the Proposal column total summary is 2, but for the Update column the total summary value should be 6 (because of the null value cell)
  • Make the summary cells on Update column editable and be able to put a numeric value on it, which is copied over to the child cells

Also there is a toggle view button which toogles the groupModel on/off while using checkboxes on both views.


  • Pass the checked state of the rows between Grouped and unGrouped models.
  • Be able to use to obtain the checked cells between both Grouped and unGrouped models.

Which we have been using
 
Code: [Select]
checkedRows = grid.Group().getCheckedNodes().map(function(rd) { return rd; });
For the groupModel.on option, using the checkbox: true,


Hopefully you can help me to make these changes possible.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: aggregate access different column and checkboxes between state
« Reply #1 on: November 25, 2019, 08:27:38 pm »
Quote
If the cell value in the Update column is null, then dont show a zero (0) on the summary cell. I have somehow managed to do this using the agg2.updates custom method

Please use custom aggregate.

Quote
If the cell value in the Update column is null, then take the value of the Proposal value into the summary total sum, but keep the cell empty (cant use formulas here), in the provided jsfiddle you can see the Proposal column total summary is 2, but for the Update column the total summary value should be 6 (because of the null value cell)

Again use custom aggregate. Complete rows information is available in custom aggregate callbacks which can be used to write any custom logic depending upon cell values in other columns.

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

Quote
Make the summary cells on Update column editable and be able to put a numeric value on it, which is copied over to the child cells

Summary values are computed from cell values, not the other way round. It's not feasible.

Quote
Pass the checked state of the rows between Grouped and unGrouped models.

It's already passed. Checked rows remain checked when grouping is toggled on / off.

Quote
Be able to use to obtain the checked cells between both Grouped and unGrouped models.

Checked state of ungrouped rows can be obtained by
Code: [Select]
grid.Checkbox('state').getCheckedNodes()

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

lhohman

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: aggregate access different column and checkboxes between state
« Reply #2 on: November 25, 2019, 10:30:03 pm »
Can you check this https://jsfiddle.net/thephoenixbird/pfram1v7/113/

And tell me why the column

Code: [Select]
   {
        title: "EAN",
        type: 'checkbox',
        cbId: 'chk',
        useLabel: true,
        dataType: "string",
        width: "20%",
        maxWidth: "20%",
        align: "left",
        dataIndx: "ean"
    },

Is not showing the checkboxes checked when I toggle between grouped and ungrouped?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: aggregate access different column and checkboxes between state
« Reply #3 on: November 26, 2019, 09:26:38 am »
Cascade checkboxes are turned off in group off state because they make sense only in case of grouping.

If you want to conserve the checkboxes between group on / off state, then you need to use normal checkboxes like OrderID column in this demo: https://paramquery.com/pro/demos/group_rows_checkbox

Please let me know whether it meets your requirements.

lhohman

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: aggregate access different column and checkboxes between state
« Reply #4 on: November 27, 2019, 09:15:32 pm »
Using your own demo and simply changing dataIndx: ['OrderID'] and setting OrderID as the first column causes the issue that im facing, the checkboxes of the OrderID column arent showing when toggling between grouped and ungrouped using the toolbar button, and also the checked status is not conserved.


Code: [Select]
    $(function () {       
        var colM = [
            { width: 100, dataIndx: "OrderID", cbId: "chkOrder", type: "checkbox", useLabel: true },
            {
                hidden: true,
                cb: {header: true},
                dataIndx: 'chkOrder',
                dataType:'bool',
                type: "checkbox"
            },
            { title: "Customer Name", width: 130, dataIndx: "ContactName" },
            { 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" },
            { 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: true,
            checkboxHead: true,           
            on: true,
            dataIndx: ['OrderID'],                       
            menuItems: ['grandSummary'],           
            summaryInTitleRow: 'all',
            titleInFirstCol: true,
            fixCols: false,
            indent: 20,
            collapsed: [false, true],
            title: [
                "{0} ({1})",
                "{0} - {1}"
            ],
            useLabel: true
        };
        var obj = {
            height: 500,
            check: function (evt, ui) {               
             
            },
            toolbar: {
                items: [
                {
                    type: 'button',
                    label: "Toggle grouping",
                    listener: function () {
                        var on = this.option('groupModel.on');                                               
                        //toggle grouping.
                        this.Group().option({ on: !on });
                    }
                }
                ]
            },
            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);

    });
« Last Edit: November 27, 2019, 09:17:23 pm by lhohman »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: aggregate access different column and checkboxes between state
« Reply #5 on: November 28, 2019, 02:23:26 pm »
Quote
the checkboxes of the OrderID column arent showing when toggling between grouped and ungrouped using the toolbar button,

I agree, checkboxes are not shown in ungrouped state when same column is used for displaying checkboxes in both grouped and non grouped state. But checkboxes are again displayed when toggled back to grouped state.

Quote
and also the checked status is not conserved.

Checked state is conserved which can be verified by checking values of
grid.Group().getCheckedNodes() in grouped state and grid.Checkbox( "OrderID" ).getCheckedNodes() in non grouped state.


Also the same old checkboxes are checked when toggled from

grouped ( check some boxes ) -> non-grouped -> grouped ( same old checkboxes are checked )
« Last Edit: November 28, 2019, 05:30:50 pm by paramvir »