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

RadGrid ResizeToFit not working in Chrome

3 Answers 192 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 2
Dennis asked on 26 Aug 2015, 11:50 PM

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

3 Answers, 1 is accepted

Sort by
0
Dennis
Top achievements
Rank 2
answered on 26 Aug 2015, 11:56 PM

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

 â€‹

0
Pavlina
Telerik team
answered on 31 Aug 2015, 01:26 PM
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
0
Dennis
Top achievements
Rank 2
answered on 01 Sep 2015, 07:12 PM

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.

 

 

Tags
Grid
Asked by
Dennis
Top achievements
Rank 2
Answers by
Dennis
Top achievements
Rank 2
Pavlina
Telerik team
Share this question
or