OLAP: How to auto size WjPivotGrid columns

Posted by: james.ingham on 18 May 2020, 5:03 pm EST

  • Posted 18 May 2020, 5:03 pm EST

    Dear support,

    I am wondering whether there is a neat way to autosize all columns based on both
      header name
      column data
    in WjPivotGrid. Apparently if I check/uncheck fields on pivot panel, the pivot grid wouldn't do autoResizeColumns itself. It's easy to demonstrate this. Just go to your official OLAP demo page (I can't paste the link because it always triggers your spam detection.)

    and execute following code in console:

    pivotGrid = wijmo.Control.getControl($('wj-pivot-grid'))

    You will see column widths have changed. This is the trick we are currently using to resize columns in PivotGrid.

    However there's still a problem here. After doing pivotGrid.autoSizeColumns(), if you click any of the column headers for sorting purpose, the column would go back to its original size... Is there a way to solve this issue?

    An interesting finding is that if you change columns width manually, e.g. drag-n-drop column borders, its width would then be persisted. It looks like changing column width manually would not only write the new width to pivotGrid.columns[index].width, but also to ngFmt.fields[index].width, however calling autoSizeColumns() function wouldn't have any effect in ngFmt.fields. I guess there might be a missing event not being triggered by autoSizeColumns() API but by manually drag-n-drop columns borders.

    We hope you can help us to find a neat way of auto sizing pivot grid columns.

  • Replied 19 May 2020, 6:05 pm EST

    Hi James,

    If autoSizeColumns is working for you, then you can keep using that in your application. For auto sizing after every update, call this method in the updatingView event of the PivotGrid.

    Regarding the changing width, your observation is correct. The autoSizeColumns only set the width of the Column instead of Field. I have asked the developers on whether this is an expected behavior or not. The internal tracking id of the case is 436598. I will update you once I will hear from them.

  • Replied 21 May 2020, 1:08 pm EST

    Hi Ashwin, thanks for your feedback. We are looking forward to the fix :-)
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels