ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: Digitalsoft on September 28, 2020, 02:01:53 pm

Title: Tree grid summary update on checkbox selection
Post by: Digitalsoft on September 28, 2020, 02:01:53 pm
In the tree grid example with checkbox , how to change the summary on group level based on check box select/unselect
Title: Re: Tree grid summary update on checkbox selection
Post by: paramvir on September 28, 2020, 03:13:46 pm
Code: [Select]
            {
                type: 'checkbox',
                label: 'summary',               
                listener: function(evt){
                    this.Tree().option({summary: evt.target.checked});
                }
            }
Title: Re: Tree grid summary update on checkbox selection
Post by: Digitalsoft on September 28, 2020, 03:27:14 pm
https://paramquery.com/forum/index.php?topic=3822.msg13876#msg13876
In this to get the checked rows on check/uncheck you asked to use 'check' event, Inside this event I want to change the summary on check/uncheck of the checkboxes
Title: Re: Tree grid summary update on checkbox selection
Post by: paramvir on September 28, 2020, 03:36:11 pm
That is what I understood from your requirement. Please elaborate if your requirement is different.
Title: Re: Tree grid summary update on checkbox selection
Post by: Digitalsoft on September 28, 2020, 03:45:17 pm
Consider the checkboxes are checked initially, so the summary is 22. If the user uncheck 'Chrome' then summary should be updated as 17. If 'Chrome' is checked again then summary should be 22.This is my requirement
Title: Re: Tree grid summary update on checkbox selection
Post by: paramvir on September 28, 2020, 09:33:03 pm
It's a new use case.

It can be solved though with help of custom aggregate and one private method ( refreshSummary ) of treegrid.

Code: [Select]
//define custom aggregate.
pq.aggregate.sumEx = function(arr, col, rows) {
    var sum = 0, di = col.dataIndx;
    rows.forEach(function(rd) {
      if (rd.pq_tree_cb) {
        sum += rd[di] * 1 || 0;
      }
    });
    return sum;
};

Code: [Select]
check: function() {
      this.Tree().refreshSummary(true); //private API       
},

https://stackblitz.com/edit/paramquery-demo-dptepp?file=index.js
Title: Re: Tree grid summary update on checkbox selection
Post by: Digitalsoft on October 16, 2020, 12:04:54 pm
Okie, How to show the summary at the top instead of showing in the bottom. i.e in the 'Android' row
Title: Re: Tree grid summary update on checkbox selection
Post by: Digitalsoft on October 19, 2020, 11:16:24 am
Hi, Any update on the above question ?
Title: Re: Tree grid summary update on checkbox selection
Post by: paramvir on October 19, 2020, 11:58:57 am
In treegrid, summary row can be displayed at the bottom of every collapsible node only.

Can you please share a screenshot where exactly do you want to display the summary so that I can look into its feasibility.
Title: Re: Tree grid summary update on checkbox selection
Post by: Digitalsoft on October 19, 2020, 12:36:58 pm
Please refer the screenshot, like this I want to show summary at top
Title: Re: Tree grid summary update on checkbox selection
Post by: paramvir on October 19, 2020, 09:45:15 pm
There is no direct configuration option to display summary in the same row as folder nodes, however Excel formulas can be used for this task.

Please check this example:

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