Posted 18 May 2020, 5:03 pm EST - Updated 3 October 2022, 6:00 am EST
Dear support,
I am wondering whether there is a neat way to autosize all columns based on both * “header name”
and * “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'))
pivotGrid.autoSizeColumns()
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.