I have a simple Aikido Webdatagrid that handles a variety of database tables and so the column names are unknown. I have the grid set up to autogenerate the columns so how can I set the pixel width to a default value? The reason is that without each and every column's width specified, I cannot view the right-most columns as they are chopped off because that's the only way to activate the horizontal scrollbar for the grid.
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="100%" DataKeyFields="ROWNUM" EnableDataViewState="True" AltItemCssClass="coloredRow">
<Behaviors>
<ig:Sorting SortingMode="Multi">
</ig:Sorting>
<ig:Selection CellClickAction="Row" RowSelectType="Single" Enabled="False">
</ig:Selection>
<ig:ColumnResizing>
</ig:ColumnResizing>
<ig:VirtualScrolling>
</ig:VirtualScrolling>
</Behaviors>
<AjaxIndicator Enabled="True" BlockArea="Control" ImageUrl="~/ig_res/Default/images/ig_progressIndicator.gif" />
</ig:WebDataGrid>
Hey,
Since you are autogenerating the columns,they do not get placed in the grid's columns collection on the server. So you can not individually set the width. If you are using 9.2, you can set the DefaultColumnWidth property to a value, say "100px", and each column should get that width. I hope this helps.
regards,
David Young
Interesting, because I was able to set the width programmatically as follows:
WebDataGrid1.DataSource = ds
WebDataGrid1.DataBind()
For i As Integer = 0 To WebDataGrid1.Columns.Count - 1
WebDataGrid1.Columns(i).Width = Unit.Pixel(250)
WebDataGrid1.Columns(i).Header.CssClass = "gridHeader"
Next
However, even though the column width did change, the all important horizontal scrollbar DID NOT appear as expected. Furthermore, the attempt at adding the css class appears to not be working or perhaps in conflict with another css property that seems to be controlling the background color of the header text.
...and yes I am using 9.2. Where is the DefaultColumnWidth? Is it in the markup or do I set it via codebehind? Example please.