Radgrid is losing the original width and the scrollbar

2 posts, 0 answers
  1. Sam Phen
    Sam Phen avatar
    10 posts
    Member since:
    Feb 2010

    Posted 14 Apr Link to this post

    Hi Telerik,

    I am using Telerik.Web.UI Version 2016.1.113.45.

    The grid which I am using is dynamically generated with static header and frozen columns and scrollbar.

    Till date, grid was loading/binding properly before I set the column width of certain columns from Pre_render event. At this moment the grid is losing it's original width due to which even scrollbar is going off. Table layout is also set to default "Auto".

    I have attached 2 screenshot of before and after behavior of the grid once I set the width in the PreRender event(code added below) explicitly from code behind

    ascx page:

    <telerik:RadGrid ID="dgEscrow" runat="server" GridLines="None" EnableEmbeddedSkins="false" AutoGenerateColumns="false" ShowFooter="true" CssClass="esGridTable">
        <HeaderStyle Font-Bold="true" HorizontalAlign="Center" />
        <ClientSettings>
            <ClientEvents OnGridCreated="setScrollerDimensionsEscrow" />
            <Scrolling AllowScroll="true" SaveScrollPosition="true" />
        </ClientSettings>
    </telerik:RadGrid>

     

    after adding the below code, the grid starting displaying in a squuezed form:

    Protected Sub dgEscrow_PreRender(sender As Object, e As EventArgs) Handles dgEscrow.PreRender
            For Each column As GridColumn In dgEscrow.MasterTableView.Columns
                If column.UniqueName = "File #_String" Then
                    column.HeaderStyle.Width = Unit.Pixel(95)
                End If
                If column.UniqueName = "Lot/Unit_String" Then
                    column.HeaderStyle.Width = Unit.Pixel(90)
                End If
                If column.UniqueName = "Status_String" Then
                    column.HeaderStyle.Width = Unit.Pixel(95)
                End If
            Next
        End Sub

    It will be of great help if you guys update me at the earliest.

    Thanks

     

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 19 Apr Link to this post

    Hello Sam,

    In this case I would suggest you either to set width for all the columns or to leave all the columns without set width. In the second case the RadGrid control will automatically calculate the required width for each column. Give this a try and see how it goes.

    Regards,
    Maria Ilieva
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top