I want all columns to autofit the grid. With the UltraWinGrid, there was a property called AutoFitStyle. I'd set it to Resize all Columns.
In UltraWebGrid, is there any equivalent?
I found that by setting ColWidthDefault="" in the html source, it seems to have similar functionality. However, I have grid where the first column in the grid is Fixed. As soon as I set the column to fixed, all column headers except the fixed column collapse like an accordian (even thought the rows look normal). As soon as you try to resize on of them, the column headers redraw and correct all columns(?????). To fix that I manually set all Column widths but this causes the Column Header and the Rows to get out of alignment somehow. Is there anything else I need to set or can do to fix this?
Here is how I set the fixed header in code.
I have an UltraWebGrid that I am binding to a strongly typed dataset in code like this...
grid.DataSource = _ds;grid.DataMember = "TableName";grid.DataBind();
In code we setup the grid's layout like so
grid.DisplayLayout.UseFixedHeaders = true;
UltraGridColumn col = gridTransaction.Columns.FromKey("ColumnName"); col.Header.Caption = "Transaction Type"; col.AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.No; col.Header.Fixed = true; col.Header.Style.HorizontalAlign = HorizontalAlign.Center; col.Width = Unit.Pixel(260); col.Move(0);
// Initialize TestMode column
col = grid.Columns.FromKey("ColumnName");col.Header.Caption = "Test/Production";col.Header.Style.HorizontalAlign = HorizontalAlign.Center;col.Width = Unit.Pixel(100);col.Move(1);
... all other columns created the same
If I comment out the 2 fixed header lines, then the grid columns will autofit correctly.
The following forum thread addresses information on how to "auto-fit" columns in WebGrid:http://forums.infragistics.com/forums/t/12670.aspx
As noted in this thread, you need to have the grid's DisplayLayout.TableLayout set to Auto in order to have your columns automatically-sized. This uses the functionaliity of an HTML table to automatically size columns, which is done by the browser.
Whenever you set UseFixedHeaders to true, or StationaryMargins to any value other than None, your grid must have its DisplayLayout.TableLayout property set to Fixed. This means that your grid columns can no longer auto-size, similar to an HTML table whose table-layout attribute is set to fixed.
In this scenario, you can likely use some JavaScript to automatically size columns for you. The following article from our online Knowledge Base shows how to do this when double-clicking between columns; it should be relatively straightforward to call similar logic from the grid's client-side InitializeLayout event instead:HOWTO: Auto size column in WebGrid when double clicking column divider
As a note, I don't recommend using this approach if you're loading a lot of data in the grid. This is because the logic requires looping through all of the rows in the grid via JavaScript, which can become very time-consuming. The logic can't be done server-side, since the server has no concept of how an individual browser instance might actually render.
Hi,
I am still facing issue with it. I have a grid displaying various coloumns with various widths. As soon as i apply StationaryMargins="Header" the size if all the cols become equal i.e total width of grid is not divided equally into all deisplaying comns equally doesnt matter if data in cells is being cut. I also have set TableLayout="Fixed". Any solution?
<
igtbl:UltraWebGrid ID="gridClientSummary" runat="server" Width="100%" Height="0%"
EnableViewState="False">
<DisplayLayout AllowSortingDefault="Yes" BorderCollapseDefault="Separate" CompactRendering="False"
HeaderClickActionDefault="SortMulti" Name="gridClientSummary" RowHeightDefault="20px"
RowSelectorsDefault="No" SelectTypeRowDefault="Single" Version="4.00" ScrollBar="Auto"
ViewType="OutlookGroupBy" ColWidthDefault="0px" StationaryMargins="Header"
TableLayout="Fixed" >
<GroupByBox Hidden="True">
<BoxStyle BackColor="ActiveBorder" BorderColor="Window"></BoxStyle>
</GroupByBox>
<GroupByRowStyleDefault BackColor="Control" BorderColor="Window">
</GroupByRowStyleDefault>
<FooterStyleDefault BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
<BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" />
</FooterStyleDefault>
<RowStyleDefault BackColor="Window" HorizontalAlign="center" BorderColor="Silver"
BorderStyle="Solid" BorderWidth="1px" Height="10px">
<BorderDetails WidthLeft="1px" WidthTop="0px" ColorLeft="Silver" WidthRight="0px"
StyleBottom="Solid" ColorBottom="Silver" WidthBottom="1px"></BorderDetails>
<Padding Left="3px" />
</RowStyleDefault>
<HeaderStyleDefault Font-Bold="False" BorderStyle="Solid" HorizontalAlign="center"
BorderColor="Black" ForeColor="Black" BackgroundImage="../Images/OutlookHeader.png"
Cursor="Hand" Height="27px" CustomRules="line-height: 10px;font-weight:Normal"
BackColor="#0080FF">
<BorderDetails WidthLeft="1px" ColorLeft="Silver" WidthRight="0px" StyleBottom="Solid"
ColorBottom="42, 77, 171" WidthBottom="0px"></BorderDetails>
</HeaderStyleDefault>
<EditCellStyleDefault BorderStyle="None" BorderWidth="0px">
</EditCellStyleDefault>
<FrameStyle BackColor="Window" BorderColor="InactiveCaption" BorderStyle="Solid"
BorderWidth="1px" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" >
</FrameStyle >
<Pager>
<PagerStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px">
BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White"></BorderDetails>
</
PagerStyle>
</Pager>
<AddNewBox Hidden="False">
<BoxStyle BackColor="Window" BorderColor="InactiveCaption" BorderStyle="Solid" BorderWidth="1px">
BoxStyle>
</AddNewBox>
<FixedHeaderStyleDefault BackgroundImage="..\Images\OutlookHeader.png">
</FixedHeaderStyleDefault>
<ActivationObject BorderStyle="None" BorderWidth="0px" AllowActivation="False">
</ActivationObject>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand>
<AddNewRow View="NotSet" Visible="NotSet">
</AddNewRow>
</igtbl:UltraGridBand>
</Bands>
</igtbl:UltraWebGrid>
<br />
Thanks
Dev
Vince,
Any advice on this?
devilindel,
I've passed your issue over to Developer Support, who will create a support case based on your issue. I've taken a look over the issue and am not certain what is happening.
Once you receive notification about the case being created, it would be very helpful if you can update the case to provide a sample project that we can run and debug.
Hey Guys ,
I am working in a similar situation I have the webgrid binded with a dataset and set all column widths as per my requirements, have 20 records per page but when i scroll down i loose the header so the user doesnt know wht hes looking at so i wanted to fix the header but when am using stationary margins and usefixedheader with setting tablelayout to fixed i loose the widths of the columns set and some times it doesnt even show any data in my grid although my dataset has data.
can ne bpdy throw some light on what is goin on ..
Thanks in Advance.
Krishna.
Krishna,
At first glance, I believe that your issue will require more in-depth research to identify than we'll be able to provide through the forums.
If you can reproduce this in a sample project that we can run and debug, then I suggest you submit a support request so that a Developer Support Engineer can assist further. We'll use that sample to research your issue and provide a resolution.
I'd offer to pass this information to DS myself, similar to what I did above, except that I'd need more technical details to do so. It'll be more expedient for both you and for us if you submit the request directly.
RE: Webgrid - v.9.1.20091
Hey Vince et al,
It seems to me that you can't have auto column sizing AND Fixed Headers? I'm not the only one having this issue.
Has anyone found a fix / workaround for this problem?
Cheers,
James
PS the goal is to have correctly sized columns with a frozen column header, ie...
grd.DisplayLayout.TableLayout = TableLayout.Auto
grd.DisplayLayout.StationaryMargins = Infragistics.WebUI.UltraWebGrid.StationaryMargins.Header