Author Topic: ParamQuery Pro Grid : Update column model grouping on data reload + col rename  (Read 3198 times)

HardikKumar.Zaveri

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 13
    • View Profile
Hi,

Can you please provide help on how to refresh column grouping data when we reload the grid / bind new data to grid after first load? Also, how to rename column grouping column name and provide title/label to first column on grand summary row?

The pivot works fine and successfully set column grouping and row grouping for the first load of data into grid. However, when I try to submit the search and refresh the grid with new data, the row grouping data has changed as per new data but for column grouping (both column name + data) does not get change based upon new data. What option does we need to set so even column grouping also refresh when we have new data to bind.

Also, I want to provide custom name to aggregate column (column grouping aggregate columns) and set custom value/ label for grant summary row on pivot grid. Can you suggest what is the setting to perform this?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Quote
how to refresh column grouping data when we reload the grid / bind new data to grid after first load

Columns ( including column grouping ) information is stored in colModel and grid data is stored in dataModel.data

To set/ refresh new columns
Code: [Select]
grid.refreshCM( new colModel )

set/bind new data
Code: [Select]
grid.option('dataModel.data', new data)
grid.refreshDataAndView()

Quote
how to rename column grouping column name


get reference to the desired column and set
column.title = new title

Quote
provide title/label to first column on grand summary row?

Titles can be defined in summary data itself as in this example: https://paramquery.com/pro/demos/summary_json

Code: [Select]
summaryData: [
            { rank:'Total', summaryRow: true, pq_fn:{revenues:'sum(C:C)', profits:'sum(D:D)', diff:'sum(E:E)' }},
            { rank:'Average', summaryRow: true, pq_fn:{revenues:'average(C:C)', profits:'average(D:D)', diff:'average(E:E)' }},           
            { rank:'Std deviation', summaryRow: true, pq_fn:{revenues:'stdev(C:C)', profits:'stdev(D:D)', diff:'stdev(E:E)' }}               
        ], 

column.render can be used for bit more advanced cases.

Quote
The pivot works fine and successfully set column grouping and row grouping for the first load of data into grid. However, when I try to submit the search and refresh the grid with new data, the row grouping data has changed as per new data but for column grouping (both column name + data) does not get change based upon new data. What option does we need to set so even column grouping also refresh when we have new data to bind.

If you want to bind new data in a pivot grid, then you would need to turn off the pivot first. Pivot can be turned on again after setting new data.

Code: [Select]
grid.Group({pivot: false}) //turn off pivot.

//bind new dataset in grid

grid.Group({pivot: on}) //turn on pivot.

Column grouping is auto generated by the pivot grid depending upon its data and you don't need to do it manually.

Quote
I want to provide custom name to aggregate column (column grouping aggregate columns) and set custom value/ label for grant summary row on pivot grid. Can you suggest what is the setting to perform this?

If you want to make any changes/ customizations in auto generated colModel of pivot grid, then pivotCM event is used.

e.g. in this example: https://paramquery.com/pro/demos/pivot_total pivotCM event is used to add css classes to aggregate columns.

If you are facing any issues, please share a jsfiddle/ plnkr.
« Last Edit: January 03, 2019, 12:22:03 pm by paramquery »

HardikKumar.Zaveri

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 13
    • View Profile
Thanks for your response.

How do we highlight column cell value on Pivot mode based on value? I mean conditional highlight/cell color on column grouping cell value.


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Please check this example on conditional styles:

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

It's same way for pivot or any other mode.