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

HeaderContextMenu ItemClick event no Firing

9 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Satz
Top achievements
Rank 1
Satz asked on 14 Nov 2013, 04:42 AM
Hi,

HeaderContextMenu OnItemClick event is not firing? 

Any help on this?

Best Regards,
Satz

9 Answers, 1 is accepted

Sort by
0
Satz
Top achievements
Rank 1
answered on 14 Nov 2013, 07:19 AM
Hi All,

MyRequirement is to show or Hide GroupFooter Template Lables when the user click the particular column Aggregates.

Any idea on this? For the I need to fire HeaderContext Menu ItemClick event  , which is not firing right now.

Best Regards,
Satz
0
Princy
Top achievements
Rank 2
answered on 14 Nov 2013, 09:49 AM
Hi Satz,

When creating custom context menu, RadGrid expects each context menu item to have an attribute with name "TableID" containing the UniqueID of either the RadGrid instance or the respective GridTableView. This value is used internally by RadGrid. You can handle
custom context menu items in the ItemClick event to implement your custom logic on postback. Please try the following code snippet.

ASPX:
<MasterTableView  EnableHeaderContextMenu="true">

C#:
protected void Page_Load(object sender, EventArgs e)
 {     
    RadGrid1.HeaderContextMenu.PreRender += new EventHandler(HeaderContextMenu_PreRender);
    RadGrid1.HeaderContextMenu.ItemClick += new RadMenuEventHandler(HeaderContextMenu_ItemClick);
 }
  
void HeaderContextMenu_PreRender(object sender, EventArgs e)
 {
    RadContextMenu menu = RadGrid1.HeaderContextMenu;
    // Add Custom Menu    
    RadMenuItem item = new RadMenuItem();
    item.Text = "Group Footer";
    item.Attributes["TableID"] = string.Empty;
    item.PostBack = true;
    menu.Items.Add(item);    
 }
void HeaderContextMenu_ItemClick(object sender, RadMenuEventArgs e)
 {
    //Your Code
 }

Thanks,
Princy


0
Satz
Top achievements
Rank 1
answered on 14 Nov 2013, 10:01 AM
Hi Princy ,

Great Thanks for the fast Reply :) . 

Actually i am not creating a Header Context Custom Menu.  I need to find the column name when the Aggregates function is clicked.  Then based on the column name i need to enable the GroupFooterTemplate Item labels(which will show the Aggregates function values).

<GroupFooterTemplate>                         
<asp:Label runat="server" ID="OrderId"  Text='<%# Eval("OrderId") %>'></asp:Label>
<asp:Label runat="server" ID="Amount" Text='<%# Eval("Amount") %>'></asp:Label>
        <asp:Label runat="server" ID="OrderType" Visible="false"   Text='<%# Eval("OrderType") %>'></asp:Label>
      </GroupFooterTemplate>

So, here i will keep the Label Id as same as Column Name. So, once the User Clicks the HeaderContext Menu of the column, then i will make the Label for the Particular column will be visible= True.

This what i have planned, do you have any other Approach?

I Hope i have explained correctly .
0
Satz
Top achievements
Rank 1
answered on 15 Nov 2013, 09:08 AM
Hi,

Any Idea or Thought on this?

Best Regards,
satz
0
Eyup
Telerik team
answered on 19 Nov 2013, 08:21 AM
Hi Satz,

I have prepared a sample RadGrid web site to demonstrate a similar functionality. Can you please run the attached application and let me know if this is the requested behavior?

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
Satz
Top achievements
Rank 1
answered on 20 Nov 2013, 05:45 AM
Hi Eyup,

Thanks for the Working Demo Application.

My requirement is that , when the user clicks the HeaderContext Menu Aggregates item(Count or Sum etc), then the GroupFooterITem Templates Lables has to be visible(Lable in the GroupFooterItem Templates).

Bscally Grid will get the data from the StoreProcedure , all the columns will be autogenerated.
(am not supposed to post the code in forum)

Thanks for the Demo, It gives me some basic Idea about groupchanging event.

Best Regards,
Satz

0
Eyup
Telerik team
answered on 25 Nov 2013, 09:34 AM
Hello Satz,

You can try the following:
<GroupFooterTemplate>
                   <asp:Label runat="server" ID="OrderId" Visible='<%# ((GridGroupFooterItem)Container).AggregatesValues["OrderID"] !=null %>'
                       Text='<%# "OrderID: "+ ((GridGroupFooterItem)Container).AggregatesValues["OrderID"] %>'></asp:Label>
                   <asp:Label runat="server" ID="Amount" Visible='<%# ((GridGroupFooterItem)Container).AggregatesValues["Freight"] !=null %>'
                       Text='<%# "Freight: "+ ((GridGroupFooterItem)Container).AggregatesValues["Freight"] %>'></asp:Label>
                   <asp:Label runat="server" ID="OrderType" Visible='<%# ((GridGroupFooterItem)Container).AggregatesValues["ShipCountry"] !=null %>'
                       Text='<%# "ShipCountry: "+ ((GridGroupFooterItem)Container).AggregatesValues["ShipCountry"] %>'></asp:Label>
               </GroupFooterTemplate>

Hope this helps. In case you have different requirements or further instructions, please feel free to send us sample screenshots or video demonstrating the desired behavior.

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
Satz
Top achievements
Rank 1
answered on 26 Nov 2013, 12:43 PM
Hi Eyup,

Thanks for the reply. 
The above code works perfectly for me.
As i said in the above post, columns are generated dynamically and my question is how to check whether the columns is in the source or not for the GroupFooterTemplate?

Best Regards,
Satz

0
Eyup
Telerik team
answered on 29 Nov 2013, 07:56 AM
Hi Satz,

The following condition checks exactly this:
Visible='<%# ((GridGroupFooterItem)Container).AggregatesValues["OrderID"] !=null %>'

Or you mean something else? Please provide some sample screenshots so we can figure out the specific requirement more clearly.

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.
Tags
Grid
Asked by
Satz
Top achievements
Rank 1
Answers by
Satz
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Eyup
Telerik team
Share this question
or