88bf必发唯一娱乐官网_www.bifa888.com
做最好的网站

看不到资源树88bf必发唯一娱乐官网

作者: 88bf必发唯一娱乐官网  发布:2019-11-26

原理非常轻便,就是树的层序遍历,在遍历进程中遇见第一个叶子节点即成功专业。

extjs 财富树 总是现身难点;看不到财富树;报错是ext未定义~那位高人给看看那块必要改
tree.html

职能如下图:代码如下: 复制代码 代码如下: var currentRootNode = null;//当前增选的根节点 function NodeClass() { //定义一个节点类 var nodeValue = null; var nextNode = null;//下一个节点 } function InitQueue { //起始化三个类别 queue = new NodeClass();//头节点为空 return queue; } function Empty { //剖断二个队列为空 var returnValue = false; if(queue.nextNode == null) { returnValue = true; } return returnValue; } function EnQueue { //入队操作 var returnValue = queue; var currentNode = queue;//头节点 while(currentNode.nextNode != null) {//current 一向到来到最后三个因素 currentNode = currentNode.nextNode; // } var tempNode = new NodeClass(); //生成多个新的要素,而且值为X tempNode.nodeValue = x; currentNode.nextNode = tempNode; //插入到最终 return returnValue; } function DeQueue { //出队操作 var returnValue = null; if(queue.nextNode != null) { //假诺队列非空 if(queue.nextNode.nextNode == null) { //倘若是最终叁个因素 returnValue = queue.nextNode.nodeValue; //得到该因素的值 queue.nextNode = null;//将头指针的queue的nextNode设置为NULL } else { returnValue = queue.nextNode.nodeValue; //获得该因素的值 queue.nextNode = queue.nextNode.nextNode; //将第二个因素的指针赋给queue的nextNode,约等于删除了第四个要素 } } return returnValue; //再次来到被剔除的第二个成分的值 } function GetHead { //得到队头成分的值 return queue.nextNode.nodeValue; } function Clear { //清空多少个队列 queue.nextNode = null; queue.nodeValue = null; } function Current_Size { //获得当前队列的尺寸 var returnValue = 0; var currentNode = queue.nextNode;//头结点 while { //从头往尾总括returnValue ; currentNode = currentNode.nextNode; //指向下八个成分 } return returnValue; //重返大小 } function findFirstCheafNode() { var childNodes = null; var targetNode = null;//待查找的对象叶子节点 var queue = null;//扶助队列 queue = InitQueue;//初始化队列 queue = EnQueue(queue,currentRootNode);//根节点入队列 while {//只要队列不空 node = DeQueue;//出队列 if {//非叶子节点 childNodes = node.childNodes; //其孩子节点从左到右依次入队列 for (var i = 0,len = childNodes.length; i < len ; i) { queue = EnQueue; } } else {//找到第多个叶子节点 return node; } } } Ext.onReady { var tree = new Ext.tree.TreePanel({ el: 'treeDiv', useArrows: true, autoScroll: true, animate: true, enableDD: true, containerScroll: true, border: false, // auto create TreeLoader loader: new Ext.tree.TreeLoader({dataUrl:'Level1.txt'}) }); var rootID = '0'; var rootnode = new Ext.tree.AsyncTreeNode({ id : rootID, text : '铁路部门', draggable : false,// 根节点不容许拖动 expanded : false }); // 为tree设置根节点 tree.setRootNode; tree.render(); tree.on('click',function {//查询树的率先个叶子节点 currentRootNode = node; var targetNode = findFirstCheafNode(); Ext.MessageBox.alert("info","当前根节点是: " currentRootNode.text " 它上面包车型客车率先个叶子节点是: " targetNode.text); }); }); var childNodes = null; var targetNode = null;//待查找的对象叶子节点 var queue = null;//帮助队列 queue = InitQueue;//开始化队列 queue = EnQueue(queue,currentRootNode);//根节点入队列 while {//只要队列不空 node = DeQueue;//出队列 if {//非叶子节点 childNodes = node.childNodes; //其孩子节点从左到右依次入队列 for (var i = 0,len = childNodes.length; i < len ; i) { queue = EnQueue; } } else {//找到第一个叶子节点 return node; } } } Ext.onReady { var tree = new Ext.tree.TreePanel({ el: 'treeDiv', useArrows: true, autoScroll: true, animate: true, enableDD: true, containerScroll: true, border: false, // auto create TreeLoader loader: new Ext.tree.TreeLoader({dataUrl:'Level1.txt'}) }); var rootID = '0'; var rootnode = new Ext.tree.AsyncTreeNode({ id : rootID, text : '铁路部', draggable : false,// 根节点不容许拖动 expanded : false }); // 为tree设置根节点 tree.setRootNode; tree.render(); tree.on('click',function {//查询树的率先个叶子节点 currentRootNode = node; var targetNode = findFirstCheafNode(); alert("当前根节点是: " currentRootNode.text " 它上边的首先个叶子节点是: " targetNode.text); }); });

Grid Examples

tree.js

/** ******************************************

  • 作者:Peter
  • 版本:1.0
  • 版权:
  • 时间:2009-3-4* ****************************************** */

Ext.onReady(function(){
Ext.BLANK_IMAGE_URL = 'images/default/s.gif';

Ext.QuickTips.init();
var mytree = new MyTree.TreePanel("28",600,400,"0");
mytree.init;

Ext.namespace;
Ext.namespace;

MyTree.TreePanel = function(treeid,width,height,rootid){
this.treeid = treeid;
this.rootid = rootid;
this.init = function(){
var tbdel = new Ext.Toolbar.Button({
id:"tbdel" this.treeid,
text:"删除",
handler:function(){
var node =tree.opNode;
if{alert("请选拔树节点!"); return false;}
MyTree.delNode;
}
});

var tbadd = new Ext.Toolbar.Button({
id:'tbadd' this.treeid,
text: '新增',
handler: function(){
var node =tree.opNode;
if{alert("请选取树节点!"); return false;}
MyTree.addNode;
}
});

var tbrename = new Ext.Toolbar.Button({
id:"tbrename" treeid,
text:"重命名",
handler:function(){

var node =tree.opNode;
if{alert("请接纳树节点!"); return false;}
MyTree.renameNode;
}
});

var tbar = new Ext.Toolbar({ id:'Toolbar' this.treeid, items : [tbadd,tbrename,tbdel] }); 

var tree = new Ext.tree.TreePanel({
id: "tree" this.treeid,
animate: true,//设置在开展和收缩节点时是不是接受动漫片效果
width: this.width,
height: this.height,
tbar: tbar,
loader: new My.TreeLoader({dataUrl:'tree.php'})

});

var root = this.root();
tree.setRootNode;
88bf必发唯一娱乐官网,tree.render(Ext.getBody;

root.expand();

tree.on("click",function{

tree.opNode = node;
node.select();

});

tree.on("contextmenu",function(node,event){
event.preventDefault();
node.select();
var depth = node.getDepth();
if(node.id!='0'){

if(depth<=2){
MyTree.rightmenulevel1(node,event);
}else{
MyTree.rightmenulevel3(node,event);
}
}

});
};
//树形区块的上升的幅度
this.width = width;
//树形区块的冲天
this.height = height;

//树形区块根节点的概念
this.root = function(){
return new Ext.tree.AsyncTreeNode({
text:"根节点",
id :this.rootid,
qtip:"根节点"
})
}

};
My.TreeLoader = function{
this.baseParams = {};
Ext.apply(this, config);
this.addEvents(

"beforeload",

"load",

"loadexception"
);
My.TreeLoader.superclass.constructor.call;
};
Ext.extend(My.TreeLoader, Ext.tree.TreeLoader, {

getParams: function{
var buf = [], bp = this.baseParams;
for(var key in bp){
if(typeof bp[key] != "function"){
buf.push(encodeURIComponent, "=", encodeURIComponent, "&");
}
}
buf.push("node=", encodeURIComponent;
return buf.join;
},
requestData : function(node, callback){
if(this.fireEvent("beforeload", this, node, callback) !== false){

 this.transId = Ext.Ajax.request({ method:this.requestMethod, url: this.dataUrl||this.url, success: this.handleResponse, failure: this.handleFailure, scope: this, argument: {callback: callback, node: node}, params: this.getParams; }else{ if(typeof callback == "function"){ callback(); } }}

});

//自定义树 --各个操作方法
MyTree.addsomelevelNode = function{
Ext.MessageBox.prompt('增添同级节点', '请输入同级节点名称:', function {
if(btn=='ok'){
if{alert('节点名称不能为空');return false;}
var newnode = new Ext.tree.TreeNode({
id:'newnode' Math.random(),//该ID应从服务器端重临
text:text
});
//node.leaf= false;
node.parentNode.appendChild;

 }

});

}
MyTree.addNode = function{
Ext.Message博克斯.prompt('增多子节点', '请输入子节点名称:', function {
if(btn=='ok'){
if{alert('节点名称不可能为空');return false;}
var newnode = new Ext.tree.TreeNode({
id:'newnode' Math.random(),//该ID应从服务器端重临
text:text
});
node.leaf= false;
node.appendChild;

 }

});
}
MyTree.renameNode = function{
Ext.MessageBox.prompt('节点重命名', '将"' node.text '" 修正为:', function {
if(btn=='ok'){
if{alert('节点名称不可能为空');return false;}

node.setText;//更新节点内容

 }

});
}
MyTree.delNode = function{
if{ alert;return false;}
Ext.MessageBox.confirm("请确认","真的要刨除那么些的节点?",function(button,text){

if(button=="yes"){
node.remove();
}

});
}
MyTree.rightmenulevel1 = function(node,event){
var menu = new Ext.menu.Menu({
id :'menu' node.id,
items : [
{
id:"level1" node.id '1',
text : "新添同级分类",
handler:function (){
MyTree.addsomelevelNode;
//alert;
}
},{ id:'level1' node.id '2',
text:'新添子分类',
handler:function(){
MyTree.addNode;
}
},{ id:'level1' node.id '3',
text:'重名名',
handler:function(){
MyTree.renameNode;
}
},{ id:'level1' node.id '5',
text:'删除',
handler:function(){
MyTree.delNode;
}
}
]
});

menu.showAt(event.getXY;
return menu;
}
MyTree.rightmenulevel3 = function(node,event){
var menu = new Ext.menu.Menu({
id :'menu' node.id,
items : [
{
id:"level3" node.id '1',
text : "新添同级分类",
handler:function (){
MyTree.addsomelevelNode;
//alert;
}
},{ id:'level3' node.id '4',
text:'重名名',
handler:function(){
MyTree.renameNode;
}
},{ id:'level3' node.id '5',
text:'删除',
handler:function(){
MyTree.delNode;
}
}
]
});

menu.showAt(event.getXY;
return menu;
}

tree.jsp

<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() "://"

  • request.getServerName() ":" request.getServerPort()
  • path;

    request.setCharacterEncoding;response.setCharacterEncoding;// 对应的是正在张开的节点id String node = request.getParameter;System.out.println;String content = "";if ("0".equals { content = "[{id:1,text:'节点阿风流罗曼蒂克'},{id:2,text:'节点阿二'}]";} else if ("1".equals { content = "[{id:11,text:'节点阿黄金年代后生可畏',leaf:false},{id:12,text:'节点阿风姿洒脱二',leaf:true}]";} else if ("2".equals { content = "[{id:21,text:'节点阿二大器晚成',leaf:true},{id:22,text:'节点阿二二',leaf:true}]";} else if ("11".equals { content = "[{id:111,text:'节点阿风流洒脱生龙活虎后生可畏',leaf:true},{id:112,text:'节点阿大器晚成风度翩翩二',leaf:true}]";}response.getWriter().print;

%>

[b]主题素材补充:[/b]
路子都改对了~依旧不对;依然EXT未定义~
[b]主题材料补充:[/b]
报错说是98行 ‘My’未定义~
[b]标题补充:[/b]
2379行~
错误时对象不帮忙次艺术或品质
[b]主题素材补充:[/b]
OO~;多谢哦~小编刚刚本人把错误调出来了~多谢你的点拨哦~那叁个firebug小编早前没怎么用过~第三回用用的不在行;上网查了半天才会了一小点~

本文由88bf必发唯一娱乐官网发布于88bf必发唯一娱乐官网,转载请注明出处:看不到资源树88bf必发唯一娱乐官网

关键词: