RadTreeView drag and drop RadWindow

4 posts, 1 answers
  1. Arindam
    Arindam avatar
    28 posts
    Member since:
    Mar 2009

    Posted 25 Mar 2009 Link to this post

    Hi

    I am generating RadTreeView dynamically, please find the code snippet below:-

    Telerik.Web.UI.RadTreeView ReportTree = new Telerik.Web.UI.RadTreeView();
    ReportTree.ID = "rptTree" + i;
    ReportTree.Height = 400;
    ReportTree.Nodes.Clear();
    ReportTree.Skin = "Telerik";
    ReportTree.EnableDragAndDrop = true;

    SqlCommand rscommand_Child = new SqlCommand(myquery, myconnection);
    DataTable dtt = new DataTable();
    SqlDataAdapter daa = new SqlDataAdapter(rscommand_Child);
    daa.Fill(dtt);

    for (int ii = 0; ii < dtt.Rows.Count; ii++)
    {
    Telerik.Web.UI.RadTreeNode tr = new Telerik.Web.UI.RadTreeNode();
    tr.Text = "" + dtt.Rows[ii][1].ToString() + "";
    ReportTree.Nodes.Add(tr);
    }
    ReportTree.OnClientNodeDragging = "openDashboards";


    Somehow openDashboards in not executing. openDashboards code snippet:-

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function openDashboards(source, dest, e)
            {
                    var oManager = GetRadWindowManager();
                    //get the clicked node
                    var Url = eventArgs.get_node(sender, eventArgs).get_value();
                    window.alert("1");
                    //get the active RadWindow
                    var oWnd = GetRadWindowManager().getActiveWindow();
                    //now we need to open a new RadWindow and ensure that
                    //such RadWindow has not been already opened.
                    var windows = oManager.get_windows();
                    for (var i=0; i < windows.length; i++)
                       {
                           var wnd = windows[i];
                           //check if an already created window has that Url
                           if (wnd.get_navigateUrl() == Url)
                           {
                               //if so - activate that window
                               wnd.setActive(true);
                               return;
                           }
                       }
                    //else open a new window
                    radopen(Url,null);
            }
            </script>
        </telerik:RadCodeBlock>


    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" VisibleOnPageLoad="false"
                        VisibleTitlebar="true" VisibleStatusbar="false"
                         ReloadOnShow ="true" ShowContentDuringLoad="true" RestrictionZoneID="dropDiv" Skin="Telerik">
    </telerik:RadWindowManager>

    Can somebody help where I am going wrong?

    Thanks!!!
    Arindam














  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 25 Mar 2009 Link to this post

    Hi Arindam,

    The openDashboards routine should be defined in the same page as the treeview. Please verify that this is the case.

    Regards,
    Albert
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Arindam
    Arindam avatar
    28 posts
    Member since:
    Mar 2009

    Posted 25 Mar 2009 Link to this post

    Yes you are right:-

    In MyDashboard.aspx page:-

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function openDashboards(source, dest, e)
            {
                    var oManager = GetRadWindowManager();
                    //get the clicked node
                    var Url = eventArgs.get_node(sender, eventArgs).get_value();
                    window.alert("1");
                    //get the active RadWindow
                    var oWnd = GetRadWindowManager().getActiveWindow();
                    //now we need to open a new RadWindow and ensure that
                    //such RadWindow has not been already opened.
                    var windows = oManager.get_windows();
                    for (var i=0; i < windows.length; i++)
                       {
                           var wnd = windows[i];
                           //check if an already created window has that Url
                           if (wnd.get_navigateUrl() == Url)
                           {
                               //if so - activate that window
                               wnd.setActive(true);
                               return;
                           }
                       }
                    //else open a new window
                    radopen(Url,null);
            }
            </script>
        </telerik:RadCodeBlock>


    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" VisibleOnPageLoad="false"
                        VisibleTitlebar="true" VisibleStatusbar="false"
                         ReloadOnShow ="true" ShowContentDuringLoad="true" RestrictionZoneID="dropDiv" Skin="Telerik">
    </telerik:RadWindowManager>




    In MyDashboard.aspx.cs page:-

    Telerik.Web.UI.RadTreeView ReportTree = new Telerik.Web.UI.RadTreeView();
    ReportTree.ID = "rptTree" + i;
    ReportTree.Height = 400;
    ReportTree.Nodes.Clear();
    ReportTree.Skin = "Telerik";
    ReportTree.EnableDragAndDrop = true;

    SqlCommand rscommand_Child = new SqlCommand(myquery, myconnection);
    DataTable dtt = new DataTable();
    SqlDataAdapter daa = new SqlDataAdapter(rscommand_Child);
    daa.Fill(dtt);

    for (int ii = 0; ii < dtt.Rows.Count; ii++)
    {
    Telerik.Web.UI.RadTreeNode tr = new Telerik.Web.UI.RadTreeNode();
    tr.Text = "" + dtt.Rows[ii][1].ToString() + "";
    ReportTree.Nodes.Add(tr);
    }
    ReportTree.OnClientNodeDragging = "openDashboards";

    So are you telling the openDashboards should be in MyDashboard.aspx.cs, if yes then how can I do that?

    Thanks!!!



    MyDashboard.aspx
  4. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 25 Mar 2009 Link to this post

    Hello Arindam,

    The declaration is ok now that you give more details. However the signature of the openDashboards method is wrong. It is declared as
    function openDashboards(source, dest, e)
    where it should be
    function openDashboards(sender, eventArgs)


    Additionally this code is wrong:

    ar Url = eventArgs.get_node(sender, eventArgs).get_value();
    It should be like this:

    var url =eventArgs.get_node().get_value()

    I suggest you check our online documentation for using the OnClientNodeDragging event.

    Kind regards,
    Albert
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top