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

on Column Hiding ,the width of the grid is decreasing.

3 Answers 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dilip
Top achievements
Rank 1
Dilip asked on 06 Sep 2011, 08:54 AM

 

 Hi,
    I have an issue with Teleric Grid Column Hiding.

 

    The Grid(with Item templates) Looks perfect when it populated with data.

    Once we are trying to hide few columns ( on Right click column Head + uncheck column names to hide) - The grid is not fitting to previous width ( or we can say 100% if assigned width ) - Its jst leaning towards left side with around 50% of the actual width.
I  want the the grid to stretch (though some of the columns are hidden),so that it maintains the previous width.

Please note that the grid has  Item templates.The reason for specifying this is,this issue is not seen in the grid without item template.

Please find my sample code below:

<telerik:RadGrid runat="server" ID="rg1" AllowCustomPaging="true"

                AllowMultiRowEdit="false" AllowPaging="true" AllowSorting="true" GridLines="Vertical"

                OnSortCommand="rg1_SortCommand" OnNeedDataSource="rg1_NeedDataSource"

                OnPageIndexChanged="rg1_PageIndexChanged" OnPageSizeChanged="rg1_PageSizeChanged"

                OnItemCreated="rg1_ItemCreated" RegisterWithScriptManager="true"

                EnableHeaderContextMenu="true" Skin="Vista" OnGroupsChanging="rg1_GroupChanging" >

                <ExportSettings HideStructureColumns="true">

                    <Csv ColumnDelimiter="Comma" RowDelimiter="NewLine" />

                </ExportSettings>

                <SortingSettings EnableSkinSortStyles="false" />

                <MasterTableView DataKeyNames="Id" ClientDataKeyNames="Id" AutoGenerateColumns="false"

                    EnableHeaderContextMenu="true" TableLayout="Fixed" AllowCustomSorting="true" >

                    <Columns>

                        <telerik:GridBoundColumn DataField="StudID" HeaderText="student ID" SortExpression=" StudID "

                            EmptyDataText="  "  HeaderStyle-Width="9%" />

                       <telerik:GridTemplateColumn UniqueName="Score" HeaderText=" Score " DataField="Score"

                            SortExpression="Score"  HeaderStyle-Width="3%" >

                            <ItemTemplate>

                                <asp:Label ID="lbl Score " runat="server" Text=""></asp:Label>

                            </ItemTemplate>

                        </telerik:GridTemplateColumn>

                                                  

                        <telerik:GridTemplateColumn UniqueName="Fav " HeaderText="Fav " DataField="Fav "

                            SortExpression="Fav "  HeaderStyle-Width="6%" >

                            <ItemTemplate>

                                <asp:CheckBox ID="chkFav " Checked="<%#Bind('Favorite') %>"                AutoPostBack="true" runat="server"

                                    OnCheckedChanged="chkFav _CheckChanged" />

                                <asp:Label ID="lblFav " runat="server" Text=""></asp:Label>

                            </ItemTemplate>

                        </telerik:GridTemplateColumn>

                    </Columns>

                    <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true"></PagerStyle>

                </MasterTableView>

                <ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="true" EnableRowHoverStyle="true">

                    <Scrolling AllowScroll="false" SaveScrollPosition="true" UseStaticHeaders="true" />

                    <Resizing AllowColumnResize="true" EnableRealTimeResize="true" ResizeGridOnColumnResize="true"

                        ClipCellContentOnResize="true" AllowResizeToFit="true" />

                    <Selecting AllowRowSelect="true" />

                    <ClientEvents OnGridCreated="gridCreated" OnRowDblClick="RowDblClick" />

                </ClientSettings>

                <HeaderContextMenu EnableScreenBoundaryDetection="true" EnableAutoScroll="true"  />

                <HeaderStyle Width="100px" />

            </telerik:RadGrid>

 

   


Can you please help us solving this issue.

 

Thanks in Advance.

 

Dilip.

 

 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Sep 2011, 02:47 PM
Hello Dilip,

Try setting MasterTableView TableLayOut  to "Fixed"
aspx:
<MasterTableView TableLayout="Fixed">

Thnaks,
Princy.
0
Dilip
Top achievements
Rank 1
answered on 07 Sep 2011, 06:54 AM
Thanks  Princy ,
But that didnt work

-Dilip
0
Iana Tsolova
Telerik team
answered on 08 Sep 2011, 09:38 AM
Hi Dilip,

The cause of the issue is that when resizing is enabled the grid table view has TableLayout Fixed which allows us to set fixed width for the columns. On the other hand, in order the columns to be automatically resized so the stretch over the whole grid width, the grid table view TableLayout should be Auto and none of the columns should have fixed width set. That is way there is no an easy way to overcome the issue you are facing. The only possible workaround I can thing of it to handle the OnColumnHidden and OnColumnShown client-side event and manually calculate and set the width of the visible columns based on the width of the grid table view.


Greetings,
Iana
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
Dilip
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dilip
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or