ExtJS How to select the last selected node before refreshing by default after refreshing

Source: Internet
Author: User

  This article mainly describes how to select the last selected node before refreshing by default after ExtJS refresh, and the friends you need can refer to the following

After the tree node is operated on, it is often necessary to reload the tree, but many businesses need to select the last selected node by default after the tree is refreshed. In this way, you must first save the previous selected node information, after reload again through the information of the node to expand layer to the node.     Query for a long time finally found a feasible solution, is through the path of the node to record the location of the node information, and then through the path from the root node to start layers, until the last node.     Complete the code below:  first is the extjs3.x version of the method:  code as follows://Get the selected node   var node = Tree.getselectionmodel (). Getselectednode ();  if (node = null) {//Not checked for overload tree   Tree.getrootnode (). Reload (); } else {//overload tree and select last selected section by default Point   var path = Node.getpath (' id ');  tree.getloader (). Load (Tree.getrootnode (),  function (TreeNode) {   Tree.expandpath (path, ' id ', function (bsucess, Olastnode) {  Tree.getselectionmodel (). Select (Olastnode);  }); }, this); }    Extjs3.0 different Extjs4.2 with the following     code as follows: Idpath = Selnode.getpath ("id" );  Tree.getstore (). Load ({  node:tree.getRootNode (),  callback:function () {  Tree.expandpath ( Idpath, ' id '); } });    It is important to note that the JSON data point of the returned tree in the background must contain the id attribute, which I did not originally have, but I put the GetPath methodparameter to a different property. It turned out to be ineffective, and finally the id attribute was added to the JSON to succeed.  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.