We have a grid where the first two colouns contain a check box and an icon. We need these columns to stay the same width when the window is resized, or when columns are added to or removed from the grid. The other columns should scale to fill the available space.
In HTML this would be easy to do. Simply specify the width for the columns that should change with a star as unit, e.g. width="1*". However, if I write this in our layout XML file, DisplayLayout.LoadLayout throws an ArgumentOutOfRangeException, whch comes ultimately from .NET's Unit class. You might think that setting max-width and min-width on the fixed columns would do the trick, but they have no effect.
Does anybody out there know how to do it?
Hi Lektor,
Thanks for the follow-up, yes I agree that this is a good idea, but unfortunately currently all Units we have (even for columns) are of type Unit, so it will be very hard to change that at this point.
Maybe you can try with percentages in Widths? (they are supported by Unit)
Thanks for the answer.
Writing a script that runs through a grid with multible bands, finding the relevant col elements, and setting the appropriate width on each (they are not the same) is not a very inviting prospect.
BTW the star unit is valid only in width attributes on col or colgroup elements. It is not valid for any other element, and it is not valid in CSS, which is no doubt why the Unit class does not accept it.
Hello Lector,
Thanks for the question - an interesting one. Unfortunately Height and Width in ASP.NET are of type Unit and the "1*" is not supported on a framework level, so you will get the same result even with a simple textbox, e.g. this is not supported in ASP.NET in general:
<asp:TextBox runat="server" ID="TextBox1" Width="1*" />
I think you might be able to do that on the client side with javascript though. You can hook the body.onload event, get the Columns and their respective Html Elements and set width this way directly, or using our CSOM (client side object model) to do that:
http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/WebGrid_Column_Object_CSOM.html
But then again, this is just a suggestion for a starting point, I really have not tried this and cannot guarantee it will work.