RadMenu not working in RadTreeView within XMLHttpPanel

4 posts, 0 answers
  1. Ravi Shankar
    Ravi  Shankar avatar
    12 posts
    Member since:
    Mar 2010

    Posted 29 Nov 2010 Link to this post

    - The RadXmlHttpPanel currently contains a RadTreeView, which has a context menu defined using RadTreeViewContextMenu.
    - The EnableClientScriptEvaluation property of RadXmlHttpPanel has been set to true, but the client side event 'OnClientContextMenuItemClicking' of the RadTreeView doesn't seem to fire while 'OnClientContextMenuShowing' event fires.
    - Have also tried by setting RegisterWithScriptManager property of RadTreeView to false, this still doesn't help

    Snippet:
    ----------
    <telerik:RadXmlHttpPanel ID="RadXmlHttpPanel1" runat="server" OnServiceRequest="XmlHttpPanel_ServiceRequest" OnClientResponseEnded="XmlHttpPanel_ResponseEnded"
    EnableClientScriptEvaluation="true" RenderMode="Block">
    <telerik:RadTreeView ID="treeView1" runat="server" OnNodeDataBound="treeView1_NodeDataBound"
    EnableViewState="false" OnClientContextMenuItemClicking="onClientContextMenuItemClicking" OnClientContextMenuShowing=”onClientContextMenuShowing”
    Height="99%" RegisterWithScriptManger="false">
    <ContextMenus>
    <telerik:RadTreeViewContextMenu ID="MainContextMenu" runat="server">
    <Items>
    <telerik:RadMenuItem Value="menuItem1" Text=" menuItem1" AccessKey="M">
    </telerik:RadMenuItem>
    <telerik:RadMenuItem Value="menuItem2" Text=" menuItem2" AccessKey="U">
    </telerik:RadMenuItem>
    </Items>
    <CollapseAnimation Type="none" />
    </telerik:RadTreeViewContextMenu>
    </ContextMenus>
    <NodeTemplate>
    <asp:CheckBox ID="NodeCheckBox" runat="server"></asp:CheckBox>
    <asp:RadioButton ID="NodeRadioButton" runat="server"></asp:RadioButton>
    </NodeTemplate>
    </telerik:RadTreeView>
    </telerik:RadXmlHttpPanel>


    Here, onClientContextMenuItemClicking doesn’t get hit, while onClientContextMenuShowing is hit.
  2. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 02 Dec 2010 Link to this post

    Hello Ravi Shankar,

    I was not able to reproduce the problem you experience with this setup. perhaps something else is causing the problem.

    Could you, please, post a runnable example so I can reproduce this at my end?
    Thanks!


    Regards,
    Nikolay Tsenkov
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Ravi Shankar
    Ravi  Shankar avatar
    12 posts
    Member since:
    Mar 2010

    Posted 07 Dec 2010 Link to this post

    Hi pls. see the sample code. Note: This issue happens only if we use client side binding.

    TreeInHttpPanel.aspx

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TreeInHttpPanel.aspx.cs"

        Inherits="RadTestApp.TreeInHttpPanel" %>

     

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

        <title></title>

     

        <script type="text/javascript">

            function onClientContextMenuItemClicking(sender, args) {

     

                var menuItem = args.get_menuItem();

                menuItem.get_menu().hide();

     

                alert(menuItem.get_value() + " Clicked");

     

            }

     

            function onClientContextMenuShowing(sender, args) {

     

            }

        </script>

     

    </head>

    <body>

        <form id="form1" runat="server">

        <div>

            <asp:ScriptManager ID="ScriptManager" runat="server" />

     

            <script type="text/javascript">

                function BindTree() {

                    var panel = $find("<%= RadXmlHttpPanel1.ClientID %>");

                    panel.set_value('data');

                }

            </script>

     

            <telerik:RadXmlHttpPanel ID="RadXmlHttpPanel1" runat="server" OnServiceRequest="XmlHttpPanel_ServiceRequest"

                EnableClientScriptEvaluation="true" RenderMode="Block">

                <telerik:RadTreeView ID="radTreeView" runat="server" EnableViewState="false" OnClientContextMenuItemClicking="onClientContextMenuItemClicking"

                    OnClientContextMenuShowing="onClientContextMenuShowing" OnNodeDataBound="radTreeView_NodeDataBound"

                    Height="99%">

                    <ContextMenus>

                        <telerik:RadTreeViewContextMenu ID="MainContextMenu" runat="server">

                            <Items>

                                <telerik:RadMenuItem Value="Cut" Text="Cut" AccessKey="X">

                                </telerik:RadMenuItem>

                                <telerik:RadMenuItem Value="Copy" Text="Copy" AccessKey="C">

                                </telerik:RadMenuItem>

                                <telerik:RadMenuItem Value="Paste" Text="Paste" AccessKey="V">

                                </telerik:RadMenuItem>

                            </Items>

                            <CollapseAnimation Type="none" />

                        </telerik:RadTreeViewContextMenu>

                    </ContextMenus>

                    <NodeTemplate>

                        <asp:CheckBox ID="NodeCheckBox" runat="server"></asp:CheckBox>

                    </NodeTemplate>

                </telerik:RadTreeView>

            </telerik:RadXmlHttpPanel>

            <input id="Button1" type="button" value="Bind From Client" onclick="BindTree();" />

            <asp:Button ID="btnBind" runat="server" Text="Bind From Server" OnClick="btnBind_Click" />

        </div>

        </form>

    </body>

    </html>

     

     

    TreeInHttpPanel.aspx.cs

     

    using System;

    using System.Collections.Generic;

    using System.Web.UI;

    using System.Web.UI.HtmlControls;

    using Telerik.Web.UI;

     

    namespace RadTestApp

    {

        public partial class TreeInHttpPanel : System.Web.UI.Page

        {

            protected void Page_Load(object sender, EventArgs e)

            {

            }

     

            private void BindTree()

            {

                radTreeView.DataSource = GetData();

     

                radTreeView.DataTextField = "Name";

                radTreeView.DataFieldID = "Id";

                radTreeView.DataFieldParentID = "ParentId";

                radTreeView.DataValueField = "Id";

     

                radTreeView.DataBind();

            }

     

            protected void radTreeView_NodeDataBound(object sender, RadTreeNodeEventArgs e)

            {

                DataSource dataItem = (DataSource)e.Node.DataItem;

                HtmlAnchor link = new HtmlAnchor();

                link.InnerText = dataItem.Name;

                link.HRef = "javascript:void(0);";

                e.Node.Controls.Add(link);

            }

     

            protected void btnBind_Click(object sender, EventArgs e)

            {

                BindTree();

            }

     

            protected void XmlHttpPanel_ServiceRequest(object sender, RadXmlHttpPanelEventArgs e)

            {

                BindTree();

            }

     

            private List<DataSource> GetData()

            {

                List<DataSource> dataSource = new List<DataSource>();

                dataSource.Add(new DataSource { Id = 1, ParentId = 0, Name = "Item 1" });

                dataSource.Add(new DataSource { Id = 2, ParentId = 1, Name = "Item 2" });

                dataSource.Add(new DataSource { Id = 3, ParentId = 1, Name = "Item 3" });

                dataSource.Add(new DataSource { Id = 4, ParentId = 2, Name = "Item 41" });

                dataSource.Add(new DataSource { Id = 5, ParentId = 2, Name = "Item 5" });

                dataSource.Add(new DataSource { Id = 6, ParentId = 5, Name = "Item 6" });

     

                return dataSource;

            }

        }

     

        class DataSource

        {

            public int Id { get; set; }

            public int ParentId { get; set; }

            public string Name { get; set; }

        }

    }

     

  4. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 10 Dec 2010 Link to this post

    Hello Ravi Shankar,

    Well, since the XmlHttPPanel skips the server page life-cycle there are a lot of event that are missed on the client, too. And one of these events is required by the treeView in order to attach handlers for the contextMenu events.

    My suggestion is to use a regular AjaxPanel instead the XmlHttpPanel.


    Regards,
    Nikolay Tsenkov
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top