[CLOSED] How to rebind TreePanel RootNode from script

  1. #1

    [CLOSED] How to rebind TreePanel RootNode from script

    Hi,

    I have tree panel with me, using same tree panel I want show next data (same tree panel with different data) in tree panel. So I was trying to fetch data by direct request and change root node of tree panel.

    Can you please tell me how to bind root node of tree panel from the script?

    Let me know if I am doing something wrong or any different approach is there.

    // Code

    //Controller
     public class SubmitController : Controller
        {
            public ActionResult Index()
            {
                return View(GetTreeNodeList());
            }
    
            public ActionResult SubmitNodes()
            {           
                return this.Direct(GetTreeNodeList1());
            }
            private List<Ext.Net.Node> GetTreeNodeList1()
            {
    
                Node root1 = new Node();          
                root1.Text = "ds";
    
                bool submit = true;
    
                for (int i = 0; i < 10; i++)
                {
                    Node node = new Node();
                    node.NodeID = (i + 1).ToString();
                    node.Text = "edoN" + (i + 1);
                    node.Leaf = false;
                    node.Expandable = true;
                    node.Checked = true;
                    node.CustomAttributes.Add(new ConfigItem("submit", JSON.Serialize(submit), ParameterMode.Raw));
                    for (int j = 0; j < 3; j++)
                    {
                        Node childNode = new Node();
                        childNode.NodeID = (j + 1).ToString();
                        childNode.Text = "edoN" + (j + 1);
                        childNode.Leaf = true;
                        childNode.Checked = true;
                        childNode.CustomAttributes.Add(new ConfigItem("submit", JSON.Serialize(submit), ParameterMode.Raw));
                        node.Children.Add(childNode);
                        submit = !submit;
                    }
                    root1.Children.Add(node);
                }
    
            
                List<Ext.Net.Node> lstNode = new List<Node>();
                lstNode.Add(root1);          
                return lstNode;
            }
            private List<Ext.Net.Node> GetTreeNodeList()
            {
    
                Node root1 = new Node();          
    
                root1.Text = "ds";
    
                bool submit = true;
    
                for (int i = 0; i < 10; i++)
                {
                    Node node = new Node();
                    node.NodeID = (i + 1).ToString();
                    node.Text = "Node" + (i + 1);
                    node.Leaf = false;
                    node.Expandable = true;
                    node.Checked = true;
                    node.CustomAttributes.Add(new ConfigItem("submit", JSON.Serialize(submit), ParameterMode.Raw));
                    for (int j = 0; j < 3; j++)
                    {
                        Node childNode = new Node();
                        childNode.NodeID = (j + 1).ToString();
                        childNode.Text = "Node" + (j + 1);
                        childNode.Leaf = true;
                        childNode.Checked = true;
                        childNode.CustomAttributes.Add(new ConfigItem("submit", JSON.Serialize(submit), ParameterMode.Raw));
                        node.Children.Add(childNode);
                        submit = !submit;
                    }
                    root1.Children.Add(node);
                }
              
                List<Ext.Net.Node> lstNode = new List<Node>();
                lstNode.Add(root1);          
                return lstNode;
            }
        }
    //View

    @model List<Ext.Net.Node>
    @{
        ViewBag.Title = "TreePanel Submit - Ext.NET MVC Examples";
        Layout = "~/Views/Shared/_BaseLayout.cshtml";
    }
    @section headtag 
    {
        <script type="text/javascript">
            function mytree(result)
            {
                var rs = result;            
                App.ds.setRootNode(rs.result[0]);
                App.ds.reload();
            }
        </script>
    }
    }
    @section example
    {
        <h1>TreePanel Submit</h1>
        @(
             Html.X().FormPanel().ID("frmTreepanel")            
                .Items(
                    Html.X().TreePanel().ID("ds")
                        .Icon(Icon.Anchor)
                        .Title("Tree")
                        .Width(550)
                        .RootVisible(false)
                        .Root(Model[0])
                      
                        .Fields(
                            Html.X().ModelField().Name("submit").Type(ModelFieldType.Boolean)
                        )
                   )
                  .Buttons(
                        Html.X().Button().DirectEvents(de=>{
                            de.Click.Url = Url.Action("SubmitNodes");
                            de.Click.Success = "mytree(result);";                        
                        })
                  )
              )
       }
    Last edited by Daniil; Dec 18, 2013 at 2:50 AM. Reason: [CLOSED]
  2. #2
    Hi @PriceRightHTML5team,

    Please take a look at:
    http://mvc.ext.net/#/TreePanel_Basic...h_Static_Tree/

Similar Threads

  1. Expanding treepanel (rootnode) on server side
    By MarianDaniel in forum 2.x Help
    Replies: 0
    Last Post: Oct 05, 2012, 7:43 AM
  2. Replies: 0
    Last Post: Jul 21, 2012, 9:08 AM
  3. [CLOSED] GridPanel Amend Store Values and Rebind
    By sadaf in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 10, 2010, 4:16 PM
  4. grid row select after rebind
    By [WP]joju in forum 1.x Help
    Replies: 3
    Last Post: Nov 24, 2009, 4:46 AM
  5. Cannot Rebind to Grid
    By simonmicheal in forum 1.x Help
    Replies: 4
    Last Post: Jul 24, 2009, 6:20 PM

Posting Permissions