This is a migrated thread and some comments may be shown as answers.

Radgrid is losing the original width and the scrollbar

1 Answer 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sam Phen
Top achievements
Rank 1
Sam Phen asked on 14 Apr 2016, 02:12 PM

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

 

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 19 Apr 2016, 11:38 AM
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.
Tags
Grid
Asked by
Sam Phen
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or