TreeView & RadAjaxManager problem

2 posts, 1 answers
  1. Laurentiu Stamat
    Laurentiu Stamat avatar
    1 posts
    Member since:
    Oct 2012

    Posted 13 Dec 2010 Link to this post

    Hello, I have a RadTreeView with TreeNodeExpandMode.ServerSide settings.
    The treeview is in a RadSplitter. I want to use RadAjaxManager and RadAjaxLoadingPanel, so the treeview do not show postback when the nodes are loaded from server. However, when I use the RadAjaxManager and RadAjaxloadingPanel, the treeview completely dissapear until the new nodes are loaded. No ajax panel shows. Here is the source code for the page:

     

     

     

    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPageTelerikFaraScriptManager.Master" AutoEventWireup="true" CodeBehind="FisiereleMele.aspx.cs" Inherits="TethysTest.Fisiere.FisiereleMele" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContinutCentru" runat="server">
      
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
      
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" 
            DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadTreeViewFisiere">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadTreeViewFisiere" 
                            LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                          
                    </UpdatedControls>
                </telerik:AjaxSetting>
                  
            </AjaxSettings>
        </telerik:RadAjaxManager>
      
                 <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1"  runat="server" 
            HorizontalAlign="Center"></telerik:RadAjaxLoadingPanel>
      
        <table style="width:100%;">
            <tr>
                <td>
                     </td>
            </tr>
            <tr>
                <td>
                  
              
      
                    <telerik:RadSplitter ID="RadSplitterFisiere" runat="server" Height="500" 
                        Width="800px" Skin="Windows7">
                        <telerik:RadPane ID="navigationPane" runat="server" Width="250">
                            <telerik:RadTreeView ID="RadTreeViewFisiere" Runat="server" 
                                AllowNodeEditing="True" DataFieldID="nivelID" DataFieldParentID="parinteID" 
                                DataTextField="nume" DataValueField="nivelID" 
                                oncontextmenuitemclick="RadTreeViewFisiere_ContextMenuItemClick" 
                                onnodecreated="RadTreeViewFisiere_NodeCreated" 
                                onnodedatabound="RadTreeViewFisiere_NodeDataBound" 
                                onnodeedit="RadTreeViewFisiere_NodeEdit" 
                                onnodeexpand="RadTreeViewFisiere_NodeExpand" Skin="Outlook">
                            </telerik:RadTreeView>
                        </telerik:RadPane>
            <telerik:RadSplitBar ID="RadSplitbar1" runat="server" CollapseMode="Forward"></telerik:RadSplitBar>
            <telerik:RadPane ID="contentPane" runat="server" Scrolling="none">
                <telerik:RadSplitter ID="RadSplitterContent" runat="server" 
                    Orientation="Horizontal">
                    <telerik:RadPane ID="topPaneContent" runat="server">
                          
                    </telerik:RadPane>
                    <telerik:RadSplitBar ID="RadSplitbar2" runat="server" CollapseMode="Forward"></telerik:RadSplitBar>
                    <telerik:RadPane ID="bottomPaneContent" runat="server">
                          
                    </telerik:RadPane>
                </telerik:RadSplitter>
            </telerik:RadPane>
        </telerik:RadSplitter>
      
                     
      
    </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="InfoLabel" runat="server" CssClass="fontUserCtrl" EnableViewState="True"></asp:Label>
                    </td>
            </tr>
        </table>
    </asp:Content>

    here is the C# source code

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    using TethysTestDAL;
    using Telerik.Web.UI;
      
    namespace TethysTest.Fisiere
    {
        public partial class FisiereleMele : TethysTest.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                try
                {
      
                    //se verifica drepturile de securitate ale userului curent pe pagina
                    Utils.TestRol(this, "CIRC");
      
                    InfoLabel.Visible = false;
      
                    if (Page.IsPostBack == false)
                    {
                          
      
                        Utils.SetMouseOver(this, "butonLinkOver", "butonLinkOut");
      
                        ViewState["currentTreeNode"] = "";
                        LoadRootNodes(RadTreeViewFisiere, TreeNodeExpandMode.ServerSide);
      
                    }
      
                    
      
                }
                catch (Exception exx)
                {
                    Utils.ShowMessage(this, exx.Message, true, InfoLabel);
                    //throw ex;
                }
      
            }
      
            public override void RefreshData()
            {
                try
                {
                    ViewState["currentTreeNode"] = "";
                    RadTreeViewFisiere.UnselectAllNodes();
                    RadTreeViewFisiere.Nodes.Clear();
                    LoadRootNodes(RadTreeViewFisiere, TreeNodeExpandMode.ServerSide);
                }
                catch (Exception exx)
                {
                    Utils.ShowMessage(this, exx.Message, true, InfoLabel);
                }
      
            }
      
      
            private void IncarcaTreeView()
            {
                TethysTestDAL.Fisiere dal = new TethysTestDAL.Fisiere();
      
                DataSet ds = dal.Arbore_SelectArboreFisiere();
      
                RadTreeViewFisiere.DataSource = ds;
                RadTreeViewFisiere.DataBind();
      
      
            }
      
            private void IncarcaTreeViewRadacina()
            {
                TethysTestDAL.Fisiere dal = new TethysTestDAL.Fisiere();
      
                DataSet ds = dal.Arbore_SelectArboreFisiereRadacina();
      
                RadTreeViewFisiere.DataSource = ds;
                RadTreeViewFisiere.DataBind();
      
      
            }
      
            private static void LoadRootNodes(RadTreeView treeView, TreeNodeExpandMode expandMode)
            {
                TethysTestDAL.Fisiere dal = new TethysTestDAL.Fisiere();
      
                DataSet ds = dal.Arbore_SelectArboreFisiereRadacina();
      
                DataTable data = ds.Tables[0];
      
                foreach (DataRow row in data.Rows)
                {
                    RadTreeNode node = new RadTreeNode();
                    node.Attributes["radacina"] = row["radacina"].ToString();
                    node.Text = row["nume"].ToString();
                    node.Value = row["nivelID"].ToString();
                    node.ToolTip = row["nume"].ToString();
                    node.ImageUrl = row["caleImagine"].ToString();
                    node.ExpandMode = expandMode;
                    if (node.Attributes["radacina"] == "0")
                    {
                        node.AllowEdit = true;
                    }
                    else
                    {
                        node.AllowEdit = false;
                    }
                    treeView.Nodes.Add(node);
                }
            }
      
      
      
      
            private static DataTable IncarcaTreeViewFrunze(string parinteID)
            {
                TethysTestDAL.Fisiere dal = new TethysTestDAL.Fisiere();
      
                DataSet ds = dal.Arbore_SelectArboreFisiereFrunze(parinteID);
      
                DataTable data = ds.Tables[0];
      
                return data;
      
            }
      
            protected void RadTreeViewFisiere_NodeDataBound(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
            {
                //try
                //{
                //    Persoana pers = (Persoana)Session["persoana"];
                //    bool supervizor = pers.Supervisor;
                //    bool powerUser = pers.IsInRole("PWU");
      
                //    DataTable data = IncarcaMeniuContextual(e.Node.Value, pers.PersoanaID.ToString(), supervizor, powerUser);
      
                //    if (data.Rows.Count > 0)
                //    {
                //        e.Node.EnableContextMenu = true;
                //        RadTreeViewContextMenu target = new RadTreeViewContextMenu();
      
                //        foreach (DataRow row in data.Rows)
                //        {
                //            RadMenuItem item = new RadMenuItem();
      
                //            item.Text = row["textMeniu"].ToString();
                //            item.Value = row["valueMeniu"].ToString();
                //            item.ToolTip = row["toolTipMeniu"].ToString();
                //            item.ImageUrl = row["imageMeniu"].ToString();
      
                //            target.Items.Add(item);
                //        }
      
                //        e.Node.ContextMenuID = target.ID;
                //        RadTreeViewFisiere.ContextMenus.Add(target);
                //    }
                //    else
                //    {
                //        e.Node.EnableContextMenu = false;
                //    }
                //}
                //catch (Exception exx)
                //{
                //    Utils.ShowMessage(this, exx.Message, true, InfoLabel);
                //    //throw ex;
                //}
      
            }
      
             
      
            private void UpdateLoadingStatusPosition(TreeViewLoadingStatusPosition statusPosition)
            {
                RadTreeViewFisiere.LoadingStatusPosition = statusPosition;
            }
      
            private static void PopulateNodeOnDemand(RadTreeNode e, TreeNodeExpandMode expandMode)
            {
                e.Nodes.Clear();
      
                DataTable data = IncarcaTreeViewFrunze(e.Value);
                //DataTable data = IncarcaTreeViewFrunze(e.Node.Attributes["nivelID"]);
      
                foreach (DataRow row in data.Rows)
                {
                    RadTreeNode node = new RadTreeNode();
                    node.Attributes["radacina"] = row["radacina"].ToString();
                    node.Text = row["nume"].ToString();
                    node.Value = row["nivelID"].ToString();
                    node.ToolTip = row["nume"].ToString();
                    node.ImageUrl = row["caleImagine"].ToString();
                    if (Convert.ToInt32(row["numarFrunze"]) > 0)
                    {
                        node.ExpandMode = expandMode;
                    }
      
                    if (node.Attributes["radacina"] == "0")
                    {
                        node.AllowEdit = true;
      
                    }
                    else
                    {
                        node.AllowEdit = false;
                    }
      
                    e.Nodes.Add(node);
                }
      
                  
      
                e.Expanded = true;
            }
      
           
      
      
      
            protected void RadTreeViewFisiere_NodeExpand(object sender, RadTreeNodeEventArgs e)
            {
                try
                {
                      
                    PopulateNodeOnDemand(e.Node, TreeNodeExpandMode.ServerSide);
                      
                      
      
                }
                catch (Exception exx)
                {
                    Utils.ShowMessage(this, exx.Message, true, InfoLabel);
                    //throw ex;
                }
            }
      
      
            private static DataTable IncarcaMeniuContextual(string nivelID, string utilizatorID, bool supervizor, bool powerUser)
            {
                TethysTestDAL.Fisiere dal = new TethysTestDAL.Fisiere();
      
                DataSet ds = dal.MeniuContextual_SelectMeniuContextual(nivelID, utilizatorID, supervizor, powerUser);
      
                DataTable data = ds.Tables[0];
      
                return data;
      
            }
      
            protected void RadTreeViewFisiere_NodeCreated(object sender, RadTreeNodeEventArgs e)
            {
                try
                {
                      
                    Persoana pers = (Persoana)Session["persoana"];
                    bool supervizor = pers.Supervisor;
                    bool powerUser = pers.IsInRole("PWU");
      
                     
      
                    DataTable data = IncarcaMeniuContextual(e.Node.Value, pers.PersoanaID.ToString(), supervizor, powerUser);
      
                    if (data.Rows.Count > 0)
                    {
                          
                        RadTreeViewContextMenu target = new RadTreeViewContextMenu();
                        target.Skin = "Default";
                        string ID = Guid.NewGuid().ToString();
                        target.ID = ID;
      
                        foreach (DataRow row in data.Rows)
                        {
                            RadMenuItem item = new RadMenuItem();
      
                            item.Text = row["textMeniu"].ToString();
                            item.Value = row["valueMeniu"].ToString();
                            item.ToolTip = row["toolTipMeniu"].ToString();
                            item.ImageUrl = row["imageMeniu"].ToString();
      
                            target.Items.Add(item);
                        }
      
                        RadTreeViewFisiere.ContextMenus.Add(target);
                        e.Node.EnableContextMenu = true;
                        e.Node.ContextMenuID = target.ID;
                   }
                    else
                    {
                        e.Node.EnableContextMenu = false;
                    }
                }
                catch (Exception exx)
                {
                    Utils.ShowMessage(this, exx.Message, true, InfoLabel);
                    //throw ex;
                }
            }
      
            protected void RadTreeViewFisiere_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e)
            {
                try
                {
                    TethysTestDAL.Fisiere dal = new TethysTestDAL.Fisiere();
                    Persoana pers = (Persoana)Session["persoana"];
                    string userHostAddress = this.NumeCalculatorClient();
      
                    RadTreeNode clickedNode = e.Node;
                    ViewState["currentTreeNode"] = clickedNode.Value;
      
      
                    switch (e.MenuItem.Value)
                    {
                        case "addFolderDirector":
      
                            dal.Arbore_InsertDirector(clickedNode.Value, pers.PersoanaID.ToString(), pers.PersoanaPKID.ToString(), pers.Nume + ", " + pers.Compartiment, userHostAddress);
      
                            ViewState["currentTreeNode"] = clickedNode.Value;
                            clickedNode.Nodes.Clear();
                            PopulateNodeOnDemand(clickedNode, TreeNodeExpandMode.ServerSide);
      
      
                        break;
      
                    }
      
                }
                catch (Exception exx)
                {
                    Utils.ShowMessage(this, exx.Message, true, InfoLabel);
                    //throw ex;
                }
            }
      
            protected void RadTreeViewFisiere_NodeEdit(object sender, RadTreeNodeEditEventArgs e)
            {
                try
                {
                    if (e.Node.Attributes["radacina"] == "1")
                    {
                        return;
                    }
      
                    string nume = e.Text;
                    e.Node.Text = nume;
      
                    TethysTestDAL.Fisiere dal = new TethysTestDAL.Fisiere();
                    Persoana pers = (Persoana)Session["persoana"];
                    string userHostAddress = this.NumeCalculatorClient();
      
                    RadTreeNode clickedNode = e.Node;
      
                    dal.Arbore_UpdateDirector(e.Node.Value, pers.PersoanaID.ToString(), pers.PersoanaPKID.ToString(), pers.Nume + ", " + pers.Compartiment, userHostAddress, nume);
      
                    ViewState["currentTreeNode"] = clickedNode.Value;
                    clickedNode.Nodes.Clear();
                    PopulateNodeOnDemand(clickedNode, TreeNodeExpandMode.ServerSide);
                }
                catch (Exception exx)
                {
                    Utils.ShowMessage(this, exx.Message, true, InfoLabel);
                    //throw ex;
                }
            }
      
      
      
          
      
      
      
        }
    }

  2. Answer
    Yana
    Admin
    Yana avatar
    4876 posts

    Posted 14 Dec 2010 Link to this post

    Hi Laurentiu,

    You just need to set Skin property of the ajax loading panel.

    Regards,
    Yana
    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