Make Dynamic Node template from code behind for the leaf nodes or option to drag (not remove) the node text onto some editor/area

2 posts, 0 answers
  1. kamii47
    kamii47 avatar
    31 posts
    Member since:
    Mar 2007

    Posted 05 Jul 2013 Link to this post

    Hi guys.I am creating tree view from some of my class object dynamically.
    What i need to do is drag(just drag not remove) the leaf node into the rich text editor text.

    I have tried to create the nodetemplate but not succcessful( other wise just add the node template in the leaf node with label)
    Following is the code of making the treeview node.


                DocumentTemaplateCompiledDto obj = DocumentTemaplateCompiledBll.GetInstance.GetDocumentTemaplateCompiledByTemplateId(Int32.Parse(ddlTemplates.SelectedValue));

    if (obj.LstSections != null && obj.LstSections.Count > 0)
                    foreach (var objSection in obj.LstSections)
                        var tNode = new RadTreeNode(objSection.SectionName);                  
                        if (obj.LstSimpleFields != null && obj.LstSimpleFields.Any(h => h.FkDocumentTemplateSectionId == objSection.DocumentTemplateSectionId))
                            var tNodeChildSimpleFields = new RadTreeNode("Simple_fields_Control");
                            foreach (var objSimplefield in obj.LstSimpleFields.FindAll(h => h.FkDocumentTemplateSectionId == objSection.DocumentTemplateSectionId))
                                var tNodeChildGridTextEntry = new RadTreeNode(objSimplefield.FieldName);
                                tNodeChildGridTextEntry.Nodes.Add(new RadTreeNode
                                    Text = objSimplefield.FieldCode,//these are the leaf node
                                    AllowEdit = true,//this I have done as a last possible option
                                    AllowDrop = true,//this I have done as a last possible option
                                    AllowDrag = true//this I have done as a last possible option

    <telerik:RadEditor ContentAreaMode="Div" runat="server" ID="RadEditor1" Height="515"
                Width="700" Visible="True">

    Please suggest me how can i achieve my desired reuslt.
    Any help guys?
  2. kamii47
    kamii47 avatar
    31 posts
    Member since:
    Mar 2007

    Posted 08 Jul 2013 Link to this post

    I have myself solve the problem to some extent

    I have made a class 

    public class MyNodeTemplate : ITemplate
            public string StrText { get; set; }
            public void InstantiateIn(Control container)
                var txt = new TextBox();
                if (!String.IsNullOrEmpty(StrText))
                    txt.Width = new Unit(StrText.Length, UnitType.Em);
                    txt.Text = StrText;

    And then with following code from code behind

    var tNodeChildGridTextEntry = new RadTreeNode(objGrid.GridName);
                                    var tGridFiledLeafNode = new RadTreeNode { Expanded = true };
                                    var objtemplate = new MyNodeTemplate { StrText = objGrid.GridCode };
                                    //tNodeChildGridTextEntry.Nodes.Add(new RadTreeNode
                                    //    Text = objGrid.GridCode,
                                    //    AllowEdit = true,
                                    //    AllowDrop = true,
                                    //    AllowDrag = true

    I were able to make my leaf node as text boxes.Problem is solve to quite extent that in text box I Ctr+C (copy )and then Psted on the text editor place easily.
    One more problem is that if i try to drag the text from the textbox it drops to any external resource [like my file in notepad++, google searchbar, e.t.c]  easily but when i drag it to telerik text editor nothing happened.
    When there is some text in label(outside treeview) and i drag it onto the text editor i were able to do it.
    Strange behavior

  3. DevCraft R3 2016 release webinar banner
Back to Top