Author Topic: Pivot Header (align and title)  (Read 822 times)

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 123
    • View Profile
Pivot Header (align and title)
« 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.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 4406
    • View Profile
Re: Pivot Header (align and title)
« Reply #1 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

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 4406
    • View Profile
Re: Pivot Header (align and title)
« Reply #2 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?
« Last Edit: August 20, 2019, 07:05:55 pm by paramvir »

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 123
    • View Profile
Re: Pivot Header (align and title)
« Reply #3 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(')', '')
})
}
})
}

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 4406
    • View Profile
Re: Pivot Header (align and title)
« Reply #4 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);
}

omerix

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 123
    • View Profile
Re: Pivot Header (align and title)
« Reply #5 on: October 01, 2019, 05:02:53 pm »
Thanks Param.