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

Retain column widths after resizing column

7 Answers 303 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Amy
Top achievements
Rank 1
Amy asked on 12 Jan 2017, 05:31 PM

Is there a way to retain the width of columns in a radgrid after resizing one or more columns?  After resizing one of the columns, if I do anything, such as navigate to the next page in the grid, then the resizing is lost and all the columns are back to the original size as if I just accessed the page.

 

Thanks!

7 Answers, 1 is accepted

Sort by
0
Amy
Top achievements
Rank 1
answered on 12 Jan 2017, 05:35 PM
Also, a similar thing happens if I right-click on one of the column headers, choose the 'columns' option, and hide one of the columns.  When navigating to the next page, or anything that causes a postback, the grid is back to it's original state.
0
Milena
Telerik team
answered on 17 Jan 2017, 04:12 PM
Hello Amy,

Please navigate to this demo page and verify that resizing is being persisted on postback. In case this behavior meet your requirements, you can setup the grid like it is demonstrated there and verify how it works on your end.

Regards,
Milena
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Amy
Top achievements
Rank 1
answered on 24 Jan 2017, 05:01 PM
Thank you!  I added in the code for the clientsettings, and the grid worked as expected.
0
Amy
Top achievements
Rank 1
answered on 07 Feb 2017, 01:33 PM

Hi,

We must have something interfering with our grid settings.  Reordering the columns work fine.  However, removing columns or resizing columns are reset to the default values if the grid is refreshed.  I've included below the relevant parts of one of the radgrids in our web application.  I left out the columns for privacy reasons; the settings on them do have filter ability, default header widths (for most columns), and autopostbackonfilter set to true.

 

<telerik:RadGrid
       ID="RadGrid1"
       runat="server"
       Skin="Windows7"
       GridLines="None"
       AutoGenerateColumns="False"
       AllowPaging="True"
       AllowSorting="True"
       AllowFilteringByColumn="True"
       EnableLinqExpressions="false"
       Width="100%"
       ShowGroupPanel="true"
       EnableHeaderContextMenu="true"
       PageSize="20">
       <MasterTableView
           DataKeyNames=[removed for privacy reasons]
           Width="100%"
           AllowMultiColumnSorting="true"
           CommandItemDisplay="Top">
           <CommandItemTemplate>
               <telerik:RadToolBar ID="RadToolBar1" runat="server" AutoPostBack="true" Skin="Windows7">
                   <Items>
                       <telerik:RadToolBarButton CommandName="clear" BorderColor="Black" BorderStyle="Solid"
                           BorderWidth="1px" />
                       <telerik:RadToolBarButton CommandName="filt" BorderColor="Black" BorderStyle="Solid"
                           BorderWidth="1px" />
                       <telerik:RadToolBarButton IsSeparator="true" />
                       <telerik:RadToolBarButton CommandName="viewall" Group="view" CheckOnClick="true"
                           BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" />
                       <telerik:RadToolBarButton CommandName="viewrej" Group="view" CheckOnClick="true"
                           BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" />
                       <telerik:RadToolBarButton CommandName="viewlim" Group="view" CheckOnClick="true"
                           BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" />
                       <telerik:RadToolBarButton IsSeparator="true" />
                       <telerik:RadToolBarButton CommandName="RebindGrid" BorderColor="Black" BorderStyle="Solid"
                           BorderWidth="1px" />
                   </Items>
               </telerik:RadToolBar>
           </CommandItemTemplate>
           <Columns>

[columns removed for privacy reasons]

</columns>
     </MasterTableView>
    <HeaderStyle HorizontalAlign="Center" Font-Size="Small" Font-Bold="true" Font-Names="Verdana" />
    <ItemStyle Font-Size="Small" VerticalAlign="Middle" Font-Names="Verdana" />
    <AlternatingItemStyle Font-Size="Small" VerticalAlign="Middle" Font-Names="Verdana" />
    <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true" Position="TopAndBottom" />
    <GroupingSettings CaseSensitive="False" ShowUnGroupButton="true" />
    <ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="true">
        <Resizing AllowRowResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True"
            AllowColumnResize="True"></Resizing>
    </ClientSettings>
    <SortingSettings SortedBackColor="Turquoise" SortedAscToolTip="Click To Reverse Sort"
        SortedDescToolTip="Click To Remove Sort" EnableSkinSortStyles="false" />
</telerik:RadGrid>

 

Thanks for any suggestions you may have!

0
Milena
Telerik team
answered on 09 Feb 2017, 11:49 AM
Hello,

We tried to simulate your project and replicate the unwanted behavior, but to no avail. Attached, you can find the testing project. Could you replicate the problem on it and give us exact steps for reproduce?

Regards,
Milena
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Amy
Top achievements
Rank 1
answered on 22 Feb 2017, 06:42 PM

Thank you for the test project.  Based on the settings you provided, I realized the grids do retain the column width after resizing. 

I have a related question.  Let me know if I should start a new post instead of continuing this post.

One thing I noticed is if you hide a column using the context menu, it will be displayed again after a postback.  Choosing the 'group by' option from the context menu seems to persist after a postback.  Is there a setting to preserve hiding columns?

0
Milena
Telerik team
answered on 27 Feb 2017, 04:55 PM
Hello,

Using the test project I am not able to replicate the behavior where the hidden columns appear after postback. Please provide a runnable project to replicate the problem on our side.

Regards,
Milena
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Amy
Top achievements
Rank 1
Answers by
Amy
Top achievements
Rank 1
Milena
Telerik team
Share this question
or