ParamQuery grid support forum

General Category => Help for ParamQuery Pro => Topic started by: 徐雪峰 on July 20, 2020, 11:25:52 pm

Title: how to add columns
Post by: 徐雪峰 on July 20, 2020, 11:25:52 pm
how to add columns in pivotCM?
Title: Re: how to add columns
Post by: paramvir on July 21, 2020, 07:34:52 am
pivotCM is an event which is used to add, modify or delete columns in colModel of pivot grid.

These 2 examples demonstrate with code how to customize colModel in pivotCM event:

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

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

Also read and understand the Columns() API which is used in above examples:

https://paramquery.com/pro/api#method-Columns
Title: Re: how to add columns
Post by: 徐雪峰 on July 21, 2020, 10:30:11 am
i have some special request. i want to add some column after pivod summary column,
for example ;
goods1             goods2         goods3               total(goods1+goods2+goods3)
2019  2020    2019  2020    2019  2020     2019  2020
but i can't do that by pivot grid
data:goods1,2019
       goods1,2020
       goods2,2019
       goods2,2020
      goods3,2019
      goods3,2020
Title: Re: how to add columns
Post by: paramvir on July 21, 2020, 11:53:38 am
Please share your attempt so far via jsfiddle or stackblitz.
Title: Re: how to add columns
Post by: paramvir on July 21, 2020, 10:11:11 pm
I've added this new example on add new column in pivot view for you.

https://paramquery.com/pro/demos/pivot_add_col
Title: Re: how to add columns
Post by: 徐雪峰 on July 22, 2020, 12:21:13 pm
thank you for your help very much.
if i can get the group data after pivot group ,and plus or minus them,
i think all my project request will be satisfied.
about the sample code,i have a question:
1, is one() a api function? 2,can the new row have a summay?
this.one('groupData', function () {
                    this.pageData().forEach(function (rd, indx) {
                        rd.new_col = indx;
                    })
                });
Title: Re: how to add columns
Post by: paramvir on July 22, 2020, 09:27:24 pm
1. yes though one('groupData') not required if summary is to be used in the column.

2. yes, please see the updated example.