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

Diplay= false does not work

5 Answers 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 08 Jul 2013, 09:22 PM
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.

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Jul 2013, 05:52 AM
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
0
Mike
Top achievements
Rank 1
answered on 09 Jul 2013, 12:24 PM
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.
0
Mike
Top achievements
Rank 1
answered on 10 Jul 2013, 03:55 PM
It seems like any grouping or resizing in the ClientSettings is causing the display=false columns to reappear. 
0
Eyup
Telerik team
answered on 11 Jul 2013, 09:26 AM
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.
0
Hary
Top achievements
Rank 1
answered on 08 Jun 2016, 06:41 AM
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";
                                }
}
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mike
Top achievements
Rank 1
Eyup
Telerik team
Hary
Top achievements
Rank 1
Share this question
or