Hello @iansriley!
Thanks for taking the time to create the new thread, I hope you understand!
To make the column fit its contents, you can use the
autoSize() column method. It is not a config option, because it needs to be run when the grid is actually drawn. So you should call it for each column you want to fit when the grid is drawn, tying the code execution to some page event.
I have found this event handler code in Sencha website and tested it on a simple grid, and it worked for me in Ext.NET 4.8, so it should be worth a try:
Post #3 in 'Auto fit column widths instead of having fix widths' Sencha thread
The catch is in the custom
autoSizeColumn: true
in the column definition, and the grid view's
refresh listener.
You can specify this custom config in WebForms/ASPX as
AutoSizeColumn="true"
without long
CustomConfig blocks. Even though it is not implemented server-side, Ext.NET passes thru what it does not support, and this will be output just how it needs to.
The refresh listener can be set just like this:
var handleViewRefresh = function(dataview) {
Ext.each(dataview.panel.columns, function(column) {
if (column.autoSizeColumn === true) {
column.autoSize();
}
})
}
And used in ASPX with this block in the grid panel definition:
<ViewConfig runat="server">
<Listeners>
<Refresh Fn="handleViewRefresh" />
</Listeners>
</ViewConfig>
Beware if you have a grid with lots of records, and
buffered rendering is enabled (it is by default). If some records are not rendered at the time the
autoSize() method runs, and a larger content cell lies in the non-rendered rows, width for the column, unless you keep firing the width code -- which will then make the grid "jump" into new column widths as the user scrolls. Explicitly disabling buffered render should ensure the width is set up right and provide a decent user experience.
Hope this helps!