ParamQuery grid support forum

General Category => Suggest new features => Topic started by: omerix on August 19, 2019, 04:47:13 pm

Title: Pivot Header (align and title)
Post by: omerix on August 19, 2019, 04:47:13 pm
Hello,

Pivot Grid De headers can't align left. (halign:left)

Although I reset total titles, it shows the title. Example: sum (Parti Sayısı)

Test Pivot SS : https://yadi.sk/i/1jvSVzRS1ljCOQ


Code: [Select]
,summaryTitle: {avg: '',count: '',max: '',min: '',stdev: '',stdevp: '',sum: ''}

Code: [Select]
,{title: 'Parti Sayısı', dataIndx: 'PartiAdet', minWidth: 60,dataType:'float',editable:false,format:'#,###',halign:'left'}

I'm using Version 6.0.
Title: Re: Pivot Header (align and title)
Post by: paramvir on August 20, 2019, 12:21:58 pm
Pivoting generates new colModel which doesn't have same properties as original colModel.

pivotCM event can be used to modify / customize the colModel in pivot mode.

Example of pivotCM usage: https://paramquery.com/pro/demos/pivot_custom
Title: Re: Pivot Header (align and title)
Post by: paramvir on August 20, 2019, 07:00:09 pm
There could be easy configuration property to copy original colModel properties to new colModel ( rather than relying on pivotCM event  ) during pivoting.

and a callback for title?
Title: Re: Pivot Header (align and title)
Post by: omerix on September 24, 2019, 03:35:05 pm
I don't know if it's the right way. But that's how I cleared the words "sum, avg".

Code: [Select]
, pivotCM: function (evt, ui) {
cm = ui.CM;
cm.forEach(function (e) {
if (typeof e.colModel == 'object') {
e.colModel.forEach(function (e) {
e.title = e.title.replace('sum', '').replace('avg', '').replace('(', '').replace(')', '')
})
}
})
}
Title: Re: Pivot Header (align and title)
Post by: paramvir on September 26, 2019, 08:59:40 am
your solution seems to work fine as long as there are fixed number of group by columns i.e., level of nesting of columns, but it might break otherwise.

Columns().each() API could be used for more generic results.

Code: [Select]
pivotCM: function(evt, ui) {               
                this.Columns().each(function(col){
                    var cm = col.colModel
                    if(!cm || !cm.length) //last level column.
                        col.title = col.title.replace('sum', '').replace('avg', '').replace('(', '').replace(')', '')
                }, ui.CM);
}
Title: Re: Pivot Header (align and title)
Post by: omerix on October 01, 2019, 05:02:53 pm
Thanks Param.