RadGrid ResizeToFit not working in Chrome

4 posts, 0 answers
  1. Dennis
    Dennis avatar
    12 posts
    Member since:
    Jan 2013

    Posted 26 Aug 2015 Link to this post

    There appears to be a problem with the ResizeToFit functionality not working in Chrome (Version 44.0.2403.157 m).

    Specifically, it appears that date fields are causing a problem.

    The RadGrid renders fine in both IE (version 11) and Firefox (version 37).

    <telerik:RadGrid ID="gridFinder" runat="server" Skin="Windows7" GroupingSettings-CaseSensitive="false" AllowSorting="True" AllowFilteringByColumn="True"
        CellSpacing="0" GridLines="both" GroupingEnabled="False" ShowGroupPanel="True" ShowHeader="True" EnableLinqExpressions="false" FilterMenu-OnClientShown="menuShowing">
        <ClientSettings>
            <Scrolling AllowScroll="false" UseStaticHeaders="true" />
            <Resizing AllowColumnResize="true" ResizeGridOnColumnResize="false" AllowResizeToFit="true" />
            <ClientEvents OnFilterMenuShowing="filterMenuShowing" />
        </ClientSettings>
        <MasterTableView PageSize="20" CommandItemDisplay="Top">
            <CommandItemSettings ShowAddNewRecordButton="false" />
            <Columns>
                <telerik:GridButtonColumn ButtonType="ImageButton" HeaderText="Select" CommandName="Select" UniqueName="SelectRecord" ImageUrl="~/images/icons/accept.png" ItemStyle-Width="18px" />
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

    Javascript to invoke the resizeToFit...

    function ResizeColumns() {
        var grid = $find("[gridFinder]");
        if (grid != null) {
            var columns = grid.get_masterTableView().get_columns();
            for (var i = 0; i < columns.length; i++) {
                columns[i].resizeToFit(false, true);
            }
        }
    }
     
    Sys.Application.add_load(ResizeColumns);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(ResizeColumns)

    FYI, the RadGrid in question resides in a user control in case that makes a difference. 

    Any ideas how to fix this?

     

     Dennis

  2. Dennis
    Dennis avatar
    12 posts
    Member since:
    Jan 2013

    Posted 26 Aug 2015 in reply to Dennis Link to this post

    Here is a snapshot of the RadGrid in question (taken from Chrome)

     ​

  3. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 31 Aug 2015 Link to this post

    Hello,

    I tested a similar scenario to the one you described and resizeToFit is working as expected in Chrome. Test the attached project and see what is the difference in your case.

    Regards,
    Pavlina
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  4. Dennis
    Dennis avatar
    12 posts
    Member since:
    Jan 2013

    Posted 01 Sep 2015 Link to this post

    Your example was not quite the same as mine.  The RadGrid in our application had auto generated columns and the column causing the problem was a GridDateTimeColumn.

    However, when I looked closer at our code-behind, I noticed that there was code to set the FilterControlWidth so that the filtering controls would fit in the resized column.  Here is the link that we used to figure out how to handle that problem originally....

    Here is the code-behind where we implemented that...

    Dim columns() As GridColumn = gridFinder.MasterTableView.AutoGeneratedColumns
    For x As Integer = beginCol To columns.Length - 1
        columns(x).FilterControlWidth = Unit.Percentage(80) ' set filter control width to 80% to fix resizeToFit problem.
    Next

    Upon further testing, it appears that Chrome had a problem with the above code so we changed it to the following to fix this problem...

    If columns(x).DataType = Type.GetType("System.DateTime") Then
        columns(x).FilterControlWidth = Unit.Pixel(100) ' set filter control width to fix resizeToFit problem.
    Else
        columns(x).FilterControlWidth = Unit.Percentage(80) ' set filter control width to 80% to fix resizeToFit problem.
    End If

     

    Thanks anyway for pointing me in the right direction.

     

     

Back to Top