Author Topic: Tree grid summary update on checkbox selection  (Read 3679 times)

Digitalsoft

  • Pro OEM
  • Newbie
  • *
  • Posts: 49
    • View Profile
Tree grid summary update on checkbox selection
« 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

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Tree grid summary update on checkbox selection
« Reply #1 on: September 28, 2020, 03:13:46 pm »
Code: [Select]
            {
                type: 'checkbox',
                label: 'summary',               
                listener: function(evt){
                    this.Tree().option({summary: evt.target.checked});
                }
            }

Digitalsoft

  • Pro OEM
  • Newbie
  • *
  • Posts: 49
    • View Profile
Re: Tree grid summary update on checkbox selection
« Reply #2 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
« Last Edit: September 28, 2020, 03:39:55 pm by Digitalsoft »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Tree grid summary update on checkbox selection
« Reply #3 on: September 28, 2020, 03:36:11 pm »
That is what I understood from your requirement. Please elaborate if your requirement is different.

Digitalsoft

  • Pro OEM
  • Newbie
  • *
  • Posts: 49
    • View Profile
Re: Tree grid summary update on checkbox selection
« Reply #4 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

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Tree grid summary update on checkbox selection
« Reply #5 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
« Last Edit: September 28, 2020, 11:37:00 pm by paramvir »

Digitalsoft

  • Pro OEM
  • Newbie
  • *
  • Posts: 49
    • View Profile
Re: Tree grid summary update on checkbox selection
« Reply #6 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

Digitalsoft

  • Pro OEM
  • Newbie
  • *
  • Posts: 49
    • View Profile
Re: Tree grid summary update on checkbox selection
« Reply #7 on: October 19, 2020, 11:16:24 am »
Hi, Any update on the above question ?
« Last Edit: October 19, 2020, 11:18:02 am by Digitalsoft »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Tree grid summary update on checkbox selection
« Reply #8 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.

Digitalsoft

  • Pro OEM
  • Newbie
  • *
  • Posts: 49
    • View Profile
Re: Tree grid summary update on checkbox selection
« Reply #9 on: October 19, 2020, 12:36:58 pm »
Please refer the screenshot, like this I want to show summary at top

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Tree grid summary update on checkbox selection
« Reply #10 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

« Last Edit: October 20, 2020, 06:27:32 am by paramvir »