Extjs tree Dynamic change load address, and dynamically load existing child nodes other node problems!__js

Source: Internet
Author: User

To complete the results shown in the following picture, there are many problems, one: backstage data is divided into two tables, a department table an employee table!

If thousands of employees, such a full load will make the data particularly slow! So it is more reasonable to use asynchronous loading.

But asynchronous loading because the data is placed in two tables, so involved, the problem of data loading source!

My idea is this, when the root node is expanded to load all departments at once, and then expand each department to load the employee!

This has a problem with loading department is a place where loading employees is another place! This requires that the data load source must be dynamically changed!

After my 3 hours of hard work finally done!

{xtype: "Treepanel", ID: ' Stafftreepanel ', Animate:true, Autoscroll:true, Containerscroll:true, Loader:new Ext.tr Ee. Treeloader ({Dataurl:serverloadalldepttreeurl}), listeners: {"click": Function (node,e) {debugger; if (node.attribut Es.strrealname) {nownode=node; Nownode.id=node.id.replace (/staff-/, ""); Loadstaffpay ();}}, "Beforeload": function ( node) {if (node.attributes.id==-1)//root Node ID is-1 {//node.ownertree.loader.baseparams node.loader=new Ext.tree.TreeLoader ({baseparams:{id:node.id}, dataurl:serverloadalldepttreeurl})} else {node.loader=new ext.tree.t Reeloader ({baseparams:{id:node.id}, dataurl:serverloadstaffbydeptidurl});//Load a department employee}}, Root:new Ext.tree.Async TreeNode ({ID: "-1", Text: All departments,//node name iconcls: ' Bumen ', expanded:true,//expand leaf:false//is leaf node}), Dropconfig : {appendonly:true}, height:446}

The Treeload.js file must change the method, otherwise there will be a problem

Ext.tree.TreeLoader.prototype.load = function (node, callback) {if (this.clearonload) {while (Node.firstchild) { Node.removechild (Node.firstchild); } if (This.dopreload (node)) {//preloaded JSON children if (typeof callback = "function") {callback ();}} if (This.dataur l| | This.url) {This.requestdata (node, callback);}},

This is all right, there is a problem, the Department ID and employee ID are the same time, it will be a problem, this how to solve the boss you find a way to do it!

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.