怎样判断EXT的延迟加载tree的加载结束时间?
4个回答
展开全部
这不是能用时间来确定的,你要找API中的事件event 找到tree加载完后的事件就行了。无论花多少时间来完成加载,加载完后来触发你要的某操作,比如选中节点。而不是单纯的使用延迟函数 如setTimeout方法,这种逻辑是不严谨的。
Ext对象注册事件 语法是 tree.on("事件名",function(){},this);
你要加载完的 我帮你找了下
由于Ext树分两种,一种是一次全部展开完的,一种是点击才展开的。所以
注册的时间是展开事件。
例子是
tree.on("expandnode", function(singelNode) {
if(这里加上你的表达条件){ singelNode.select();//此节点被选中
} }, this);
这个是当各个节点展开的时候都会调用此方法,如果满足条件,则此节点被选中
Ext对象注册事件 语法是 tree.on("事件名",function(){},this);
你要加载完的 我帮你找了下
由于Ext树分两种,一种是一次全部展开完的,一种是点击才展开的。所以
注册的时间是展开事件。
例子是
tree.on("expandnode", function(singelNode) {
if(这里加上你的表达条件){ singelNode.select();//此节点被选中
} }, this);
这个是当各个节点展开的时候都会调用此方法,如果满足条件,则此节点被选中
展开全部
<html>
<title>demo</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css"/>
<script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext/ext-all.js"></script>
</head>
<body>
<script>
Ext.onReady(function (){
var tree =new Ext.tree.TreePanel({
renderTo:document.body,
width: 180,
xtype:'treepanel',
split:true,
minSize: 160,
maxSize: 300,
autoScroll:true,
autoShow:false,
rootVisible:false,
bodyStyle:'padding:0px 10px',
listeners:{
'click':function (no){
}
},
loader: new Ext.tree.TreeLoader({
dataUrl:'tree.json',
listeners:{load:function (treepanel , currentNode , response){
var t = currentNode.getOwnerTree() ;
var node = t.getNodeById("node-2");
node.select() ;
//alert(node.attributes.text)
}},
requestMethod: 'GET'
}),
root: new Ext.tree.AsyncTreeNode({
id: 'helpTreeRootNode',
text: 'temp',
expanded: true
})
});
},this);
</script>
</body>
<!--
content of tree.json
[{"text":"node-1","id":"node-1","leaf":true,"expanded":true,"disabled":false},
{"text":"node-2","id":"node-2","leaf":true,"expanded":true,"disabled":false},
{"text":"node-3","id":"node-3","leaf":true,"expanded":true,"disabled":false},
{"text":"node-4","id":"node-4","leaf":true,"expanded":true,"disabled":false},
{"text":"node-5","id":"node-5","leaf":true,"expanded":true,"disabled":false},
{"text":"node-6","id":"node-6","leaf":true,"expanded":true,"disabled":false}]
-->
</html>
<title>demo</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css"/>
<script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="ext/ext-all.js"></script>
</head>
<body>
<script>
Ext.onReady(function (){
var tree =new Ext.tree.TreePanel({
renderTo:document.body,
width: 180,
xtype:'treepanel',
split:true,
minSize: 160,
maxSize: 300,
autoScroll:true,
autoShow:false,
rootVisible:false,
bodyStyle:'padding:0px 10px',
listeners:{
'click':function (no){
}
},
loader: new Ext.tree.TreeLoader({
dataUrl:'tree.json',
listeners:{load:function (treepanel , currentNode , response){
var t = currentNode.getOwnerTree() ;
var node = t.getNodeById("node-2");
node.select() ;
//alert(node.attributes.text)
}},
requestMethod: 'GET'
}),
root: new Ext.tree.AsyncTreeNode({
id: 'helpTreeRootNode',
text: 'temp',
expanded: true
})
});
},this);
</script>
</body>
<!--
content of tree.json
[{"text":"node-1","id":"node-1","leaf":true,"expanded":true,"disabled":false},
{"text":"node-2","id":"node-2","leaf":true,"expanded":true,"disabled":false},
{"text":"node-3","id":"node-3","leaf":true,"expanded":true,"disabled":false},
{"text":"node-4","id":"node-4","leaf":true,"expanded":true,"disabled":false},
{"text":"node-5","id":"node-5","leaf":true,"expanded":true,"disabled":false},
{"text":"node-6","id":"node-6","leaf":true,"expanded":true,"disabled":false}]
-->
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
要想选中第一层的节点 只要在初始数据加载成功的CallBack里选中即可
如果 要选中更深层时 必须先把全部的数据加载完,也就是要先全部展开
如果 要选中更深层时 必须先把全部的数据加载完,也就是要先全部展开
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
坐下等高人
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询