I have a grid that has lots of columns. When I was using GridView, I could make it easily fit on the screen without horizontal scrolling by setting CssClass for each column and setting widths (and visibility via display:none or display: table-cell) so from site to site we could adjust what columns the customer wants to see and their default width via the stylesheet.
So now I am trying to retrofit UltraWebGrid in as the means of evaluating whether or not to move to this product, and I have yet to find a way to be able to manage the widths of the columns so that they all fit wihout horizontal scrolling. I have Wrap="true" in both the header and item rows and that works, so that if I resize a column I get the necessary wrapping, but my initial column widths are coming out al one width - too wide for most columns) and I get a long horizontal scrollbar.
My DisplayLayout section is below.
As you can see, I tried following another post that indicated how to get as-wide-as-it-takes type behavior, but that didn't work (unless as-wide-as-it-takes means setting all columns to the width that the widest column needs), but then as-wide-as-it-takes, even if it differs column to column, still isn;t what I want anyway, though better than what I am getting. Of course, ideally, I'd like to stil be able to use the CSS stylesheet classes to control it all, but any approach that allows me to have column widths each be set appropriately so I avoid horizontal scrolling is fine.
Down to one day to finish my eval and report back to my boss.
Thanks.
You should be able to set Grid.DisplayLayout.ColumnWidthDefault to "0px", and then set each column's width to a specific "<N>px".
This can be done either in the designer, or programmatically.
Setting ColumnWidthDefault to "0px" does not allow the columns to automatically size to whatever is needed, but now the user cannot manipulate the width further. That is, I now no longer have a horizontal scrollbar when I load the page, but when the user hovers the mouse over the header, I see the little <--> icon to resize a column and can drag it, but when I let go of the mouse button no column resizing occurs. The only change I made was setting ColumnWidthDefault to "0px" in the DisplayLayout section of my ascx. I still need to go and set widths of individual columns, but I don;t see how that would impact what i am now seeing. Is it not possible to control the widths as they initially appear while allowing the user to also resize the coluymns?
Oh, and thanks for the quick reply on the first step of this, anyway. This is one of only a couple areas left that I need to reach a favorable result on to be able to complete the eval with a recommendation to go with this grid. It's one of the things GridView can't do (user column resize) so it's one of the things that without which, I can;t justify moving away from GridView.
typo in my response - first sentence. Setting ColumnWidthDefault to "0px" does now allow...
other than that, still need to allow user resize while controlling column width.
Yet more info. When I put actual Width settings in my UltraGridColumn definitions, they have no effect. Since setting ColumnWidthDefault to "0px", the columns always and only ever are the minimum width needed - with wrapping, to display the data rows in the grid. I'm thinking I still must be doing something wrong. I can't imagine that user ability to adjust column widths would be restricted to columns all starting out one width.
-Ed
Sorry for this being piecemeal, but as I learn more, it will avoid anyone chasing down the wrong issues. I discovered that the ability to resize the columns as the user was not as non-functional as I thought. The grid comes up displaying the columns all minimum width for the data (despite even setting wider widths on some of the UltraGridColumn definitions.) I cannot seem to resize NAY columns as long as that is the case. But, if I tried enough times, I seem to be able to drag the overall grid width (right end) to the right, making it bigger. When i do so, all the columns seem to resize slightly. After I have done that, I then CAN effect grid size changes by dragging row widths around, but still it doesn;t obey what i do as the user. I drag a column width to the right to make it bigger, and instead the whole grid changes size by the amount I dragged that column edge, and then the columns are all resize fractionally to total the new grid size.
So, summarizing it a different way, as currently set:
1) All columns are coming up minimum width of the data in the rows and none can be resized.
2) After successfully dragging the right edge of the grid to the right (takes several attempts), the columns all resize by a small amount to fit the new overall grid width.
3) After the above, attmpted changes to a column width affects grid width but in such a way that all columns get resized to fill the new overall grid width.
Hopefully it is just some setting I have that is autoresizing all columns instead of obeying the new size of the single column.