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 2016 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" />
            <ClientEvents OnGridCreated="setScrollerDimensionsEscrow" />
            <Scrolling AllowScroll="true" SaveScrollPosition="true" />


    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
        End Sub

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



  2. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 19 Apr 2016 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.

    Maria Ilieva
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top