jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Troubles with "autoresizecolumns"
This topic contains 3 replies, has 2 voices, and was last updated by Peter Stoev 11 years, 6 months ago.
-
Author
-
Hi,
In my other thread “Dynamic show/hide of Groups Header” I mentioned having some problems with column sizes when calling “refresh”. This occurred only sometimes and so I descided to investigate … with success. The root cause for my problems is the “autoresizecolumns” function of jqxGrid. Apparently the resizing effect of “autoresizecolumns” is only temporary. It lasts only until the next time you call “render”. Calling “render” on a grid will (re)size all columns to the size that they had before “autoresizecolumns” was called.
Since I do offer “autoresizecolumns” as a feature in the application for the customer I’d really aprpeciate it if the effect would be mroe permanent. Can this be achieved somehow ? Preferably in some way that does not involve avoiding “render” at all costs
Here is a fiddle that shows the problem:
http://jsfiddle.net/_stephan_/8M3PM/1/Since I created it for the other problem I’m having with the groups header it works like this: activating the grouping for any column (via column menu) will result in a call to call “render”. Initially all columns have the automatically determined optimum size. The call to “render” will make all columns jump back to the size they had before “autoresizecolumns”, which is 50 pixel.
Regards,
StephanHi stephan,
“autoresizecolumns” auto-calculates the column sizes. If you re-render the Grid, the widget will use its Original settings set up during the initialization of the widget.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
From a jqxGrid user point of view thats a rather unexpected behaviour, at least thats how I see it. After all I call “autoresizecolumn(s)” because I want the column(s) to resize permanently not temporarily.
But that aside I’d like to share the solution that I have found for my problem with the temporary nature of “autoresizecolumns”. Calling ‘setcolumnproperty’ with parameter ‘width’ causes a permanent resizing of a column that survices calls to “render”. By combining it with “autoresizecolumns” we can achieve a permanent automatic column resizing:
var colDefs = mTableObject.jqxGrid('columns').records;for ( var idx = 0; idx < colDefs.length; idx++) { mTableObject.jqxGrid('autoresizecolumn', colDefs[idx].datafield, 'all'); mTableObject.jqxGrid('setcolumnproperty', colDefs[idx].datafield, 'width', colDefs[idx].width);}
Regards,
StephanHi Stephan,
I am not going to argue what is right or how it should work. I have just wanted to let you know how the “autoresizecolumns” method works and that we would not make further changes about it in the future.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.