Diplay= false does not work

6 posts, 0 answers
  1. Mike
    Mike avatar
    338 posts
    Member since:
    Jun 2008

    Posted 08 Jul 2013 Link to this post

    I have a Radgrid and have several columns set to Display=False and when a user sorts or expands on a column the hidden columns appear and I even set the itemstyle-width to 0.

     

    <telerik:RadGrid ID="RadGrid1" 

    AllowMultiRowSelection="True" 

    AllowSorting="True"

    AllowNaturalSort="True"  

    AllowPaging="True"
    AlternatingItemStyle-HorizontalAlign="Center" 

    AutoGenerateColumns="false"  

    BackColor="#ffffff" 

    CellPadding="2"  

    CellSpacing="2" 

    GridLines="None"  

    GroupingEnabled="True" 

    HeaderStyle-Height="20"  

    Height="580px" 

    OnNeedDataSource="RadGrid1_NeedDataSource"  

    OnItemDataBound="RadGrid1_ItemDataBound" 

    OnSortCommand="RadGrid1_SortCommand"  

    OnExcelExportCellFormatting="RadGrid1_ExcelExportCellFormatting" 

    SelectedItemStyle-ForeColor="#000000"  

    PageSize="15" 

    ShowFooter="True"  

    ShowHeader="True" 

    ShowGroupPanel="True"  

    ShowStatusBar="True" 

    EnableEmbeddedSkins="False"  

    Skin="Nuts" 

    Width="100%"  

    Visible="true" 

    runat="server">  
    -- Now for the columns

    <telerik:GridBoundColumn DataField="status_id" ItemStyle-Width="0" Display="False" />

    <telerik:GridBoundColumn DataField="request_id" ItemStyle-Width="0" Display="False" />  

    <telerik:GridBoundColumn DataField="refresh_time" ItemStyle-Width="0" Display="False" /> 

    <telerik:GridBoundColumn DataField="number_of_days" ItemStyle-Width="0" Display="False" />  

    <telerik:GridBoundColumn DataField="request_number" UniqueName="RequestNumber" ItemStyle-Width="0" Display="False" />

    <ClientSettings AllowDragToGroup="True" EnablePostBackOnRowClick="False">

            <Resizing AllowColumnResize="True" AllowRowResize="False" ResizeGridOnColumnResize="False" ClipCellContentOnResize="True" EnableRealTimeResize="False" />
             <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" FrozenColumnsCount="3" />
             <Selecting AllowRowSelect="True" />
    </ClientSettings>

    Any help would be appreciated and I have attached an image.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 09 Jul 2013 Link to this post

    Hi Mike,

    I have tried to replicate your issue but no avail.I see that you have set all the bound columns visibility to false. I couldn't replicate with that code.Here is the code i tried with some column made visible. Please let know if any concern .

    ASPX:
    <telerik:RadGrid ID="RadGrid1" AllowMultiRowSelection="True" AllowSorting="True"
        AllowNaturalSort="True" AllowPaging="True" AlternatingItemStyle-HorizontalAlign="Center"
        AutoGenerateColumns="false" BackColor="#ffffff" CellPadding="2" CellSpacing="2"
        GridLines="None" GroupingEnabled="True" HeaderStyle-Height="20" Height="580px"
        SelectedItemStyle-ForeColor="#000000" PageSize="15" ShowFooter="True" ShowHeader="True"    ShowGroupPanel="True" ShowStatusBar="True" Width="100%" Visible="true" runat="server">
        <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn DataField="OrderID" HeaderText="OrderID" />
                <telerik:GridBoundColumn DataField="ShipVia" HeaderText="ShipVia" />
                <telerik:GridBoundColumn DataField="EmployeeID" Display="false" />
                <telerik:GridBoundColumn DataField="ShipCity" ItemStyle-Width="0" Display="False" />
                <telerik:GridBoundColumn DataField="CustomerID" ItemStyle-Width="0" Display="False" />
            </Columns>
        </MasterTableView>
        <ClientSettings AllowDragToGroup="True" EnablePostBackOnRowClick="False">
            <Resizing AllowColumnResize="True" AllowRowResize="False" ResizeGridOnColumnResize="False"
                ClipCellContentOnResize="True" EnableRealTimeResize="False" />
            <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" FrozenColumnsCount="2" />
            <Selecting AllowRowSelect="True" />
        </ClientSettings>
    </telerik:RadGrid>

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mike
    Mike avatar
    338 posts
    Member since:
    Jun 2008

    Posted 09 Jul 2013 Link to this post

    Prciny,

    Thank you for the quick response.

    I am not using visible=false because if I do the values are not passed in EventArgs.  The only way to pass them and keep them hidden without using datakeys is to use Display=false.
  5. Mike
    Mike avatar
    338 posts
    Member since:
    Jun 2008

    Posted 10 Jul 2013 Link to this post

    It seems like any grouping or resizing in the ClientSettings is causing the display=false columns to reappear. 
  6. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 11 Jul 2013 Link to this post

    Hello Mike,

    Please note that having hidden columns (with Display property set to false) or hiding/showing columns and frozen columns are not supported at the same time as stated in the following topic:
    http://www.telerik.com/help/aspnet-ajax/grid-frozen-columns.html

    I hope the clarification was helpful.

    Regards,
    Eyup
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  7. Hary
    Hary avatar
    2 posts
    Member since:
    Jun 2016

    Posted 08 Jun in reply to Mike Link to this post

    Hi Mike, yesterday i got same issue. After doing some investigation i found that when we set any columns to display=false, its apply apply a style on that column i.e. style ="Display:none". When we did some update on grid than that style is like  style =" " thats why these hidden column visible. To solve this issue i assigned css class to these column which had display=false. Sample code is given below in my case i created custom control using RadGrid.
     <style type="text/css">

      .ItemStyle {
        display:none;
            }
        </style>
     protected void RadGrid1_PreRender(object sender, EventArgs e)
            {
                GridBoundColumn boundColumn = Column as GridBoundColumn;
                                 
                                    boundColumn.Display = Convert.ToBoolean(Convert.ToInt32(GridSchema.ColumnVisibleSplit[i].ToString()));
                                    if (!boundColumn.Display)
                                    {
                                        boundColumn.HeaderStyle.CssClass = "ItemStyle";
                                        boundColumn.ItemStyle.CssClass = "ItemStyle";
                                        boundColumn.FooterStyle.CssClass = "ItemStyle";
                                    }
    }
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017