EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: akashana on March 20, 2019, 07:52:30 PM



Title: Pivot Grid Totals
Post by: akashana on March 20, 2019, 07:52:30 PM
Hi,

Pivot grid was generated perfectly as shown in attachment with the following source data.
[
  {
    "Name": "Employee 1001",
    "Period": "Jan-18",
    "Amount": 6504
  },
  {
    "Name": "Employee 1001",
    "Period": "Jan-18",
    "Amount": 4648
  }....]

However, I am stuck at displaying column total and row total i.e. Total for each month and Total for each employee. Can you please help ?

Regards,


Title: Re: Pivot Grid Totals
Post by: akashana on March 20, 2019, 07:56:43 PM
Somehow the attachment was missing in my earlier post.


Title: Re: Pivot Grid Totals
Post by: akashana on March 25, 2019, 02:53:03 AM
Hi,

Any update on this ?

Regards,


Title: Re: Pivot Grid Totals
Post by: jarry on March 25, 2019, 08:27:01 AM
What is the 'column total and row total'? Please describe it much clearly.


Title: Re: Pivot Grid Totals
Post by: akashana on March 25, 2019, 09:07:04 PM
Hi,

Please see the attached image for totals.

Regards,


Title: Re: Pivot Grid Totals
Post by: jarry on March 26, 2019, 12:44:32 AM
The 'aggregate' property is available to set the summary row and column. Make sure to download the newest  file from https://www.jeasyui.com/extension/pivotgrid.php

Code:
pivot:{
    rows:['Country','Category'],
    columns:['Color'],
    values:[
        {field:'Price',op:'max'},
        {field:'Discount',op:'sum'}
    ],
    aggregate: {
        column: {
            field: '_total',
            title: 'Total',
            width: 100,
            align: 'right'
        },
        footer: {
            frozenColumnTitle: 'Total'
        }
    }
},


Title: Re: Pivot Grid Totals
Post by: akashana on March 27, 2019, 05:24:13 AM
Hi,

I downloaded the latest file but it seems that aggregate functionality doesn't work. Even in the sample file pivotgrid.html, the code for totals is not included.

Can you please share a working example ?

Thanks & Best Regards,



Title: Re: Pivot Grid Totals
Post by: jarry on March 27, 2019, 08:48:07 AM
Please look at this example https://www.jeasyui.com/demo/test/test6.html


Title: Re: Pivot Grid Totals
Post by: akashana on March 27, 2019, 07:25:29 PM
Hi,

Thanks. But this aggregate property didn't work in the version I downloaded from https://www.jeasyui.com/extension/downloads/jquery-easyui-pivotgrid.zip. Did I download it from wrong location ?

Satisfied with your controls and bought one commercial license just now.

One question. If there is only one dimension for aggregation, can I hide it ? See image

Best Regards,


Title: Re: Pivot Grid Totals
Post by: akashana on March 27, 2019, 08:08:05 PM
Hi,

Noticed one small issue. FrozenColumnTitle is not displayed. Please see image.

Regards,


Title: Re: Pivot Grid Totals
Post by: jarry on March 28, 2019, 02:42:52 AM
Set the 'frozenColumnTitle' property correctly to display the frozen column title. Download the extension from https://www.jeasyui.com/extension/downloads/jquery-easyui-pivotgrid.zip. The example 'pivotgrid.html' in the zip file shows how to set 'aggregate' property.


Title: Re: Pivot Grid Totals
Post by: akashana on March 28, 2019, 05:00:39 AM
Hi,

It's done. I handled using the following code.

onLoadSuccess: function(){
               $('#pg').pivotgrid('collapseAll');
               var opt = $('#pg').pivotgrid('options');
               var rows = opt.pivot.rows;
               var header = rows[0];
               var title = $(this).data('datagrid').dc.header1.find('.datagrid-cell>span:first');
               title.html('<span style="font-weight:bold">'+ header +'</span>');
            }

You may close the ticket.

Regards,


Title: Re: Pivot Grid Totals
Post by: nijino on August 12, 2019, 07:31:38 PM
Hello,

i download jquery-easyui-pivotgrid.zip and test it.
the total is the correct value * numbers of rows

jquery.pivotgrid.js
i modify the line #123, footerRow[fields] = value / opts.pivot.rows.length;

Please help to check if this the correct fix.


Thanks.


Title: Re: Pivot Grid Totals
Post by: jarry on August 13, 2019, 01:16:17 AM
No problem with this code.
Code:
footerRow[fields[i]] = value;