Column Resizing After Post Back

3 replies. Last post: June 21, 2012 11:50 PM by Hans Kristian
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Ahmed DajaniMember

Hi,

I'm having a problem with my webgrid columns resizing after postback. I've attached a before an after image to illustrate the problem. During the loading of the page, I add the rows in the code behind. I then post back to the server for processing, and rebind the grid. Code is below:


<ISWebGrid:WebGrid ID="wbCompareResults" runat="server" Height="75%" Width="100%" UseDefaultStyle="true" EnableWebResources="Always"
                            CustomSchemaRetrieval="UseWebGrid">
            <RootTable GridLineStyle="NotSet">
                <Columns>
                    <ISWebGrid:WebGridColumn ColumnType="Custom" Width="35px" AllowSizing="No" /> 
                    <ISWebGrid:WebGridColumn ColumnType="Text" Width="35px" Name="Tran" AllowSizing="No" />
                    <ISWebGrid:WebGridColumn ColumnType="Text" Width="50px" Name="Num" AllowSizing="No" />
                    <ISWebGrid:WebGridColumn ColumnType="Text" Width="10px" AllowSizing="No" />
                    <ISWebGrid:WebGridColumn ColumnType="Text" Width="50px" Name="LT" AllowSizing="No" />
                    <ISWebGrid:WebGridColumn ColumnType="Text" Width="10px" AllowSizing="No" />
                    <ISWebGrid:WebGridColumn ColumnType="Text" Width="50px" Name="BT" AllowSizing="No" />
                    <ISWebGrid:WebGridColumn ColumnType="Text" Width="10px" AllowSizing="No" />
                    <ISWebGrid:WebGridColumn ColumnType="Text" Width="50px" Name="BC" AllowSizing="No" />
                    <ISWebGrid:WebGridColumn ColumnType="Text" Width="10px" AllowSizing="No" />
                    <%--<ISWebGrid:WebGridColumn ColumnType="Custom" IsAutoWidth="true" AllowSizing="Yes" Name="Description" Caption="Description" />
                    <ISWebGrid:WebGridColumn ColumnType="Custom" IsAutoWidth="true" AllowSizing="Yes" Name="Field" Caption="Field" />
                    <ISWebGrid:WebGridColumn ColumnType="Custom" IsAutoWidth="true" AllowSizing="Yes" Name="Value" Caption="Value" />--%>
                    <ISWebGrid:WebGridColumn ColumnType="Custom" Width="725px" AllowSizing="Yes" Name="Description" Caption="Description" />
                    <ISWebGrid:WebGridColumn ColumnType="Custom" Width="110px" AllowSizing="Yes" Name="Field" Caption="Field" />
                    <ISWebGrid:WebGridColumn ColumnType="Custom" Width="110px" AllowSizing="Yes" Name="Value" Caption="Value" />
                </Columns>
            </RootTable>
            <LayoutSettings AllowEdit="No" 
                AlternatingColors="false" 
                GridLines="Horizontal" 
                PagingMode="None"
                AutoHeight="true"
                AutoFitColumns="false"
                StatusBarVisible="false">
                <AlternatingRowStyle CustomRules="text-overflow: ellipsis; overflow: hidden;" Wrap="false" BackColor="White" Font-Size="8pt" Font-Names="Arial Monospaced"></AlternatingRowStyle>
                <RowStyle CustomRules="text-overflow: ellipsis; overflow: hidden;" Wrap="false" BackColor="White" Font-Size="8pt" Font-Names="Arial Monospaced"></RowStyle>
            </LayoutSettings>
        </ISWebGrid:WebGrid>

Code behind - this is what is execute after the post back:

''' <summary>
    ''' binds this list to the grid
    ''' </summary>
    ''' <param name="results"></param>
    ''' <remarks></remarks>
    Private Sub BindGrid(ByVal results As List(Of String()))
        ' Note (XXX): we can't bind the grid by simply setting the datasource property since this is a list of string arrays
        ' we have to iterate through the list and add each row manually
        If results IsNot Nothing Then
            For i As Integer = 0 To results.Count - 1
                Dim data As String() = results(i)
                Me.wbCompareResults.RootTable.Rows().Add(New ISNet.WebUI.WebGrid.WebGridRow(data))
            Next
        End If
    End Sub

Everything seems to bind just find, but my first row is never sized as it was.

Thanks for your help!

All times are GMT -5. The time now is 12:18 AM.
Previous Next