Hello Dear
My very basic problem is that i want to do a "autosize" of all the gridcolumns. Maybe autosize is wrong so please let me explain;
Just imagine a grid where a cell value in Column A has a wide string value or content. In column B there aren't such wide strings in the cells. Is it possible to tell the grid that it shall take a column width so all cell content can be displayed? I don't know how the Grid builds it size but in HTML manner this is not a big deal i think?
I found some articles in the knowledge base to set this via javascript, but I just wanted to know if this is possible without doing it on the client via javascript.
If there is absolutly no way to let the grid do this, please let me also know.
Thanks for your help
Hi,
Thanks for subitting you query with Infragistics Forums.
There is a property in UltraWebGrid's DisplayLayout named "TableLayout", which needs to be set to Auto for the columns to resize themselves. By default this property is set to Fixed.
Hope this helps.
Thanks
Thanks for you answer, this was one of the first properties I'd try to set, but it caused nothing in my sample grid. Is there any additional property to get the behavior?
Tried this property with AllowColSizing=Free and Fixed
Any idea?
Sorry, my fault. My ColWidthDefault was set to a value which caused the columns to not size it self by default. Your Post was that what i was looking for.
And for all the guys out there which may need to do this stuff in javascript; (This was my fallback)
function AutoSize() { var grid = igtbl_getGridById("UltraWebGrid1"); var band = grid.Bands[0]; var columns = band.Columns; var rows = grid.Rows; for (var columnIndex = 0; columnIndex < columns.length; columnIndex++) { var col = columns[columnIndex]; var length = 0; for (var rowIndex = 0; rowIndex < rows.length; rowIndex++) { var row = rows.getRow(rowIndex); var cell = row.getCell(columnIndex); if (cell.Element.firstChild.offsetWidth > length) { length = cell.Element.firstChild.offsetWidth; } } col.setWidth(length); } }
Callable in <body onload="AutoSize()">
I'm glad that the problem is solved.
Regards