Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > TreeView > RadTreeNodeData missing AllowEdit

Answered RadTreeNodeData missing AllowEdit

Feed from this thread
  • Posted on Jan 31, 2012 (permalink)

    According to
    http://demos.telerik.com/aspnet-ajax/treeview/examples/programming/loadondemandmodes/defaultcs.aspx
    I'm using Page Method

    But I have a problem, for somes node I need set AllowEdit = False.

    I try use this solution
    http://www.telerik.com/community/forums/aspnet-ajax/treeview/allowedit-ignored-in-radtreeview.aspx

    but this does not load ParentNodes..

    How I can set this??

    regards,

    this is my code (i do all by code)


    public UpdatePanel CreateTreeViewObject(Page pg)
            {

                UpdatePanel updatePanel = new UpdatePanel {ID = "upTreeView", UpdateMode = UpdatePanelUpdateMode.Always};          
              

                HtmlGenericControl workspaceDiv = new HtmlGenericControl("DIV") { ID = "WSWorkspace" };
                
                HtmlGenericControl wsTreeview = new HtmlGenericControl("DIV") { ID = "WsTreeView" };

                RadTreeView radTreeView = new RadTreeView { ID = "tvWorkspace" };
                

                RadTreeNode parentNode =
                    new RadTreeNode(_resources.GetString("Workspace", new CultureInfo(_culture)))
                    {
                        Expanded = true,
                        AllowEdit = false,
                        AllowDrag = false,
                        AllowDrop = false,
                        ContextMenuID = "MainContextMenu",
                        Value = "0"
                    };

                radTreeView.Nodes.Add(parentNode);

                LoadRootNodes(parentNode, TreeNodeExpandMode.WebService);
             
                System.Web.HttpContext.Current.Session["tvWorkspace"] = radTreeView;
                radTreeView.AllowNodeEditing = true;
                radTreeView.MultipleSelect = false;
                radTreeView.CheckBoxes = true;
                
                
                radTreeView.EnableDragAndDrop = true;
                radTreeView.EnableDragAndDropBetweenNodes = true;

                radTreeView.ContextMenuItemClick += RadTree_Contextmenutitem;
                radTreeView.NodeDrop += RadTreeView1_NodeDrop;
                radTreeView.NodeCheck += RadTreeView_NodeCheck;
                radTreeView.NodeEdit += RadTreeView1_NodeEdit;

                //radTreeView.OnClientNodeDataBound = "OnClientNodeDataBoundHandler";

                //radTreeView.NodeTemplate = new MyTemplateNode();
                
                radTreeView.ContextMenus.Add(new TreeViewContextMenus().CreateWsContextMenu());
                radTreeView.ContextMenus.Add(new TreeViewContextMenus().CreateFolderContextMenu());
                radTreeView.ContextMenus.Add(new TreeViewContextMenus().CreateDocumentContextMenu());
                radTreeView.ContextMenus.Add(new TreeViewContextMenus().CommonActionMenu());


                radTreeView.WebServiceSettings.Path = pg.ID;
                radTreeView.WebServiceSettings.Method = "GetNodes";
               

                wsTreeview.Controls.Add(radTreeView);
                workspaceDiv.Controls.Add(wsTreeview);

                updatePanel.ContentTemplateContainer.Controls.Add(workspaceDiv);

                return updatePanel;

            }



            private static void LoadRootNodes(RadTreeNode parentNode, TreeNodeExpandMode expandMode)
            {
                
                List<smFolder> folderLst = new smOrganization().GetParentNodes(App.CurrentUserId());

                foreach (smFolder folder in folderLst)
                {
                    RadTreeNode node = new RadTreeNode
                                           {
                                               Text = folder.FolderName,
                                               Value = folder.FolderId.ToString(),
                                               ImageUrl = "~/UI/Images/folder.png",
                                               ExpandMode = expandMode
                                           };
                    node.Attributes["Type"] = "F";

                    parentNode.Nodes.Add(node);
                }
            }


            [WebMethod]
            public static RadTreeNodeData[] GetNodes(RadTreeNodeData node)
            {
               
                List<smWorkspace> childList = new smOrganization().GetChildNodes(Convert.ToInt32(node.Value));

                List<RadTreeNodeData> result = new List<RadTreeNodeData>();

                foreach (smWorkspace nodeChild in childList)
                {

                    RadTreeNodeData childNode = new RadTreeNodeData();

                    if (nodeChild.File != null)
                    {
                        childNode.Text = nodeChild.File.FileName;
                        childNode.Value = nodeChild.File.FileId.ToString();
                        childNode.ImageUrl = "~/UI/Images/folder.png";
                        childNode.ContextMenuID = "DocumentContextMenu";
                        childNode.Attributes["Type"] = "D";
                        childNode.Attributes["path"] = nodeChild.File.FileFullPath;
                        childNode.Attributes["documnetStatus"] = nodeChild.File.DocumentStatusId.ToString();
                        childNode.Attributes["securityLevel"] = nodeChild.File.SecurityLevelId.ToString();
                        childNode.Attributes["AllowEdit"] = false;

                        string extension = Components.CommonFunctions.GetExtensionFile(nodeChild.File.FileFullPath);
                        childNode.ImageUrl = CommonFunctions.GetDocumentIcon(extension);
                        
                    }
                    else if (nodeChild.Folder != null)
                    {
                        childNode.Text = nodeChild.Folder.FolderName;
                        childNode.Value = nodeChild.Folder.FolderId.ToString();
                        childNode.ImageUrl = "~/UI/Images/folder.png";
                        childNode.ContextMenuID = "FolderContextMenu";
                        childNode.Attributes["Type"] = "F";
                        
                    }

                    childNode.ExpandMode = TreeNodeExpandMode.WebService;
                    result.Add(childNode);
                }

                return result.ToArray();
            }


    Julyhttp://www.telerik.com/community/forums/aspnet-ajax/treeview/allowedit-ignored-in-radtreeview.aspx

    Reply

  • Answer Plamen Zdravkov Plamen Zdravkov admin's avatar

    Posted on Feb 3, 2012 (permalink)

    Hello,

     
    You can get the value of the attribute "AllowEdit" in onClinentNodePopulated event and set the allowEdit property of the node according to this attribute. Here is a sample code:

    function OnClientNodePopulated(sender, args) {
               args.get_node()._children._array[0].get_attributes().getAttribute("AllowEdit");
               args.get_node().set_allowEdit(args.get_node()._children._array[0].get_attributes().getAttribute("AllowEdit"));
               alert( args.get_node().get_allowEdit());
           }

    Hope this will be helpful help.

    Regards,
    Plamen Zdravkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now

    Reply

  • Posted on Feb 3, 2012 (permalink)

    Thanks! But Didn't work correctly...
    Steps:
    1- Click on node 1 --> does not allow edit (OK)
    2- click on node 2 --> Ok
    3- Click on node 1 --> ALLOW EDIT


    regards

    Reply

  • Answer Plamen Zdravkov Plamen Zdravkov admin's avatar

    Posted on Feb 8, 2012 (permalink)

    Hello Julieta,

     
    I tried the steps that you posted but could not reproduce any unusual behavior. I added the previous code to the Load on Demand Modes and it worked as expected - the node that is expanded cannot be edited any more after the child nodes are loaded. Here you can see the video of the test. 

    If you meant something else or your scenario is somehow different, please let me know how to reproduce the behavior.

    All the best,
    Plamen Zdravkov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > TreeView > RadTreeNodeData missing AllowEdit
Related resources for "RadTreeNodeData missing AllowEdit"

ASP.NET TreeView Features  |   Documentation   |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]