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.
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.