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

[Solved] Clicking on ContextMenu doesn't fire onContextMenuItemClick event

1 Answer 268 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
weerdboil
Top achievements
Rank 2
weerdboil asked on 11 Apr 2008, 11:05 AM
Hello,

I have a user control with RadTreeView which nodes are populated from database and has one context menu.
ASPX code:

<telerik:RadTreeView ID="radCategoriesTree" Runat="server" OnNodeDrop="radCategoriesTree_HandleDrop" Skin="Telerik"
        OnNodeExpand="radCategoriesTree_NodeExpand" EnableDragAndDrop="true" OnContextMenuItemClick="radCategoriesTree_ContextMenuItemClick"
        AllowNodeEditing="true"> 
       
        <ContextMenus>
            <telerik:RadTreeViewContextMenu Skin="Telerik" ID="RootCategoryMenu" runat="server" >
                <Items>
                    <telerik:RadMenuItem Value="ViewProducts" Text="View Products" ToolTip="View products in category." PostBack="true"></telerik:RadMenuItem>
                    <telerik:RadMenuItem Value="NewCategory" Text="Add Subcategory" ></telerik:RadMenuItem>
                    <telerik:RadMenuItem Value="Rename" Text="Rename" ></telerik:RadMenuItem>
                    <telerik:RadMenuItem IsSeparator="true"></telerik:RadMenuItem>
                    <telerik:RadMenuItem Value="Delete" Text="Delete"></telerik:RadMenuItem>
                </Items>
            </telerik:RadTreeViewContextMenu>
        </ContextMenus>          
        </telerik:RadTreeView>

 When I right-click on a node, menu is shown, but when context menu item is clicked nothing happens. here is the node binding code:

while (reader.Read())
            {
                RadTreeNode node = new RadTreeNode();
                node.Text = reader["product_category_name"].ToString();
                node.Value = reader["product_category_id"].ToString();
                if ((bool)reader["product_category_hasSubcategories"])
                    node.Expanded = true;
                node.EnableContextMenu = true;
                node.ContextMenuID = "RootCategoryMenu";
                node.PostBack = true;
                nodes.Add(node);
            }

And here the event handling function:

protected void radCategoriesTree_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
        {
            switch (e.MenuItem.Value)
            {
                case "ViewProducts":
                    //e.Node.Value - categoryId
                    DataSet set = ... reader here ..
                    radProductsGrid.DataSource = set;
                    radProductsGrid.DataBind();
                    radCategoriesTree.SelectedNodes.Clear();
                    break;
                case "NewCategory":
                    break;
                case "Rename":
                    break;
                case "Delete":
                    break;
            }
        }

When  clicking the expand button on TreeView the events are fired fine, but not from contextMenu. Any ideas ??

edit: I forgot to add that clicking the menu item will bind data to RadGrid, and here was the problem. When I removed RadGrid from control all events fire properly ... weird

I found an error on Java Console in my browser, maybe it could be helpfull:

 'Sys.WebForms.PageRequestManager' is null or not an object

Does it mean that I can't use RadGrid and RadTreeView with context menu in same control ?

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 14 Apr 2008, 03:10 PM
Hi weerdboil,

You can use RadTreeView and RadGrid in the same page without problems.

Can you check your web.config file for existence of the following tag:

<xhtmlConformance mode="Legacy"/>

You will need to remove it in order to use ASP.NET AJAX (RadControls "Prometheus" are built on top of ASP.NET AJAX). Please, find more details here.


Let me know if this helps.

All the best,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TreeView
Asked by
weerdboil
Top achievements
Rank 2
Answers by
Veselin Vasilev
Telerik team
Share this question
or