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

EnableHeaderContextMenu issue

3 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Meera
Top achievements
Rank 1
Meera asked on 10 May 2012, 11:27 AM
In my radgrid I want to display filter,grouping,sorting options for columns. So I made EnableHeaderContextMenu="true".
<rad:RadGrid ID="myGrid" runat="server" 
                               AllowSorting="True"
                               AutoGenerateColumns="false"
                               AllowPaging="True" GridLines="Both" GroupingEnabled="true" AllowFilteringByColumn="true"
                               EnableAJAX="True" EnableHeaderContextMenu="true" ShowGroupPanel="false" ShowFooter="True"
                               PageSize="20" EnableHeaderContextFilterMenu="true"
                               AllowMultiRowEdit="true" AllowMultiRowSelection="true"
                               OnNeedDataSource="myGrid_NeedDataSource"
                               OnDetailTableDataBind="myGrid_DetailedTableDataBind" 
                               OnItemDataBound="myGrid_OnItemDataBound"
                               OnPreRender="myGrid_OnPreRender">
                              <ClientSettings EnableRowHoverStyle="true" Resizing-AllowColumnResize="True" AllowColumnsReorder="True"
                                   ReorderColumnsOnClient="True" EnablePostBackOnRowClick="true">
                                   <Selecting AllowRowSelect="True" />
                                   <ClientEvents OnGridCreated="OnGridCreated" />
</ClientSettings>

The problem here is , it doesnt show checkboxed for displaying/hiding columns.
Where as other pages are working fine.

Appriciate your help.



Thanks

3 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 11 May 2012, 07:29 PM
ASP:

In order to display the header context filter menu for a grid you should only need to set EnableHeaderContextMenu="true", as you've done.The list of the columns should be available to hide/display whether the columns are created dynamically or declaratively. However, each column's Visible property should be set to true (its default value).

I want to be sure you've referenced the Grid/Header Context Filter Menu online demo for insights.

Can you post more of your code to help in identifying the problem?

Cheers!
0
Meera
Top achievements
Rank 1
answered on 14 May 2012, 09:19 AM
Hello jumpStart,

Thanks for the reply. I have seent his link and applied required properties, still its not showing checkboxes.
Here is the code
<rad:RadGrid ID="myGrid" runat="server" OnNeedDataSource="myGrid_NeedDataSource"
                                AllowFilteringByColumn="True"
                               AllowSorting="True" AllowPaging="true" GridLines="None" EnableLinqExpressions="false"
                               AutoGenerateColumns="false" EnableHeaderContextMenu="true" EnableHeaderContextFilterMenu="true"
                               enableajax="True" OnDetailTableDataBind="myGrid_DetailedTableDataBind" 
                               OnItemDataBound="myGrid_OnItemDataBound"
                               OnPreRender="myGrid_OnPreRender">
                               <ClientSettings EnableRowHoverStyle="true" Resizing-AllowColumnResize="True">
                                   <Resizing AllowColumnResize="true" />
                                   <ClientEvents OnGridCreated="OnGridCreated" />
                                   <Selecting AllowRowSelect="true"/>
                               </ClientSettings>
                                 <PagerStyle Mode="NextPrev" PagerTextFormat="" BackColor="Transparent"></PagerStyle>
                               <MasterTableView IsFilterItemExpanded="false" DataKeyNames="IncentiveAccrualId" HierarchyLoadMode="ServerOnDemand">
                               
                                   <Columns>
                                       <rad:GridBoundColumn DataField="IncentivePayableId" HeaderText="IncentivePayableId"
                                           ReadOnly="True" HeaderStyle-Width="50px" Visible="false" />
                                       <rad:GridTemplateColumn DataField="Now" GroupByExpression="Now Group by Now" UniqueName="Now"
                                           InitializeTemplatesFirst="false" HeaderStyle-Width="100" HeaderText="Now">
                                           <HeaderTemplate>
                                               <table>
                                                   <tr>
                                                       <td>
                                                           <asp:LinkButton runat="server" CommandArgument="Now" CommandName="Sort" Text="Now"></asp:LinkButton>
                                                       </td>
                                                       <td>
                                                           <img src="../../Images/arrow_down.png" style="margin-top: 5px; margin-left: 5px;
                                                               cursor: pointer" onclick='ShowColumnHeaderMenu(event,"Now")' alt="Show context menu" />
                                                       </td>
                                                   </tr>
                                               </table>
                                           </HeaderTemplate>
                                           <ItemTemplate>
                                               <asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Now", "{0:N2}")%>'></asp:Label>
                                           </ItemTemplate>
                                       </rad:GridTemplateColumn>
                                       <rad:GridTemplateColumn DataField="Before" GroupByExpression="Before Group by Before"
                                           UniqueName="Before" InitializeTemplatesFirst="false" HeaderStyle-Width="100"
                                           HeaderText="Before">
                                           <HeaderTemplate>
                                               <table>
                                                   <tr>
                                                       <td>
                                                           <asp:LinkButton runat="server" CommandArgument="Before" CommandName="Sort" Text="Before"></asp:LinkButton>
                                                       </td>
                                                       <td>
                                                           <img src="../../Images/arrow_down.png" style="margin-top: 5px; margin-left: 5px;
                                                               cursor: pointer" onclick='ShowColumnHeaderMenu(event,"Before")' alt="Show context menu" />
                                                       </td>
                                                   </tr>
                                               </table>
                                           </HeaderTemplate>
                                           <ItemTemplate>
                                               <asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Before", "{0:N2}")%>'></asp:Label>
                                           </ItemTemplate>
                                       </rad:GridTemplateColumn>
                                       <rad:GridTemplateColumn DataField="Difference" GroupByExpression="Difference Group by Difference"
                                           UniqueName="Difference" InitializeTemplatesFirst="false" HeaderStyle-Width="100"
                                           HeaderText="Difference">
                                           <HeaderTemplate>
                                               <table>
                                                   <tr>
                                                       <td>
                                                           <asp:LinkButton runat="server" CommandArgument="Difference" CommandName="Sort" Text="Difference"></asp:LinkButton>
                                                       </td>
                                                       <td>
                                                           <img src="../../Images/arrow_down.png" style="margin-top: 5px; margin-left: 5px;
                                                               cursor: pointer" onclick='ShowColumnHeaderMenu(event,"Difference")' alt="Show context menu" />
                                                       </td>
                                                   </tr>
                                               </table>
                                           </HeaderTemplate>
                                           <ItemTemplate>
                                               <asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Difference", "{0:N2}")%>'></asp:Label>
                                           </ItemTemplate>
                                       </rad:GridTemplateColumn>
                                   </Columns>
                                   <RowIndicatorColumn>
                                       <HeaderStyle Width="25px" Height="15px"></HeaderStyle>
                                   </RowIndicatorColumn>
                                   <ExpandCollapseColumn>
                                       <HeaderStyle Width="20px"></HeaderStyle>
                                   </ExpandCollapseColumn>
                               </MasterTableView>
                               <HeaderStyle Height="25px" />
                               <ItemStyle Wrap="false" CssClass="Row50" />
                               <AlternatingItemStyle Wrap="false" CssClass="Row50" />
                               <SelectedItemStyle />
                               <FilterMenu EnableImageSprites="False">
                               </FilterMenu>
                           </rad:RadGrid>

and attached is the screenshot.
Thanks for help.
0
Tsvetina
Telerik team
answered on 15 May 2012, 07:04 AM
Hello,

Can you confirm that you do not have any styles on your page that could hide the checkboxes? Also, what is your RadControls version? I tried to replicate the problem using RadControls version Q1 2012 SP1 but to no avail. You can find my test page attached to this message.

Regards,
Tsvetina
the Telerik team
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 their blog feed now.
Tags
Grid
Asked by
Meera
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Meera
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or