- 浏览: 11558 次
- 性别:
- 来自: China
最近访客 更多访客>>
最新评论
-
wangangonline:
ie出不来,firebox可以,但是中为不显示
基于ext2.0的含有checkBox的tree -
379548695:
<div class='quote_title' ...
基于ext2.0的含有checkBox的tree -
aiwobucuo:
你的JSON数据组是怎么样生成的啊
基于ext2.0的含有checkBox的tree -
c_mingze@163.com:
我也写了一个复选框的树
但是我想 知道怎么实现、特定情况下把页 ...
基于ext2.0的含有checkBox的tree -
小蚯蚓:
<div class='quote_title' ...
基于ext2.0的含有checkBox的tree
http://www.smellcode.cn/index.php/javascript/jiyuext20dehanyoucheckboxdetree/
感谢分享,这一句很关键!
评论
8 楼
wangangonline
2008-08-09
ie出不来,firebox可以,但是中为不显示
7 楼
379548695
2008-08-09
<div class='quote_title'>小蚯蚓 写道</div>
<div class='quote_div'>
<div class='quote_title'>smellcode 写道</div>
<div class='quote_div'>
<div class='quote_title'>引用</div>
<div class='quote_div'>mercuryzhang:看你给的连接,只指出了一个方法。不知道checkboxtree的实现和普通的tree的实现有啥区别,能不能把这个发出来看看啊</div>
你其实可以用最简单的树来实现,不用什么extend<br/>
<pre name='code' class='html'><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Reorder TreePanel</title>
<link rel="stylesheet" type="text/css" href="../../../support/resources/css/ext-all.css" />
<script type="text/javascript" src="../../../support/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../../support/js/ext-all-debug.js"></script>
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = "../../../support/resources/images/default/s.gif"
var tree = null;
Ext.onReady(function(){
// shorthand
var Tree = Ext.tree;
tree = new Tree.TreePanel({
el:'tree-div',
autoScroll:true,
animate:true,
enableDD:true,
containerScroll: true,
loader: new Tree.TreeLoader({
dataUrl:'xmmapjson.json'
}),
rootVisible: false
});
tree.on('checkchange', function(node, checked) {
node.expand();
node.attributes.checked = checked;
node.eachChild(function(child) {
child.ui.toggleCheck(checked);
child.attributes.checked = checked;
child.fireEvent('checkchange', child, checked);
});
}, tree);
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'root',
draggable:false,
id:'root'
});
tree.setRootNode(root);
// render the tree
tree.render();
root.expand();
});
var fn = function() {
alert(tree.getChecked('id'));
};
</script>
</head>
<body scroll="no">
<b>Checked Nodes: </b> <input type="text" id="cn" value="" size="40" autocomplete="off" /><br />
<div id="tree-div" style="overflow:auto; height:300px;width:300px;border:1px solid #c3daf9;"></div>
<input type="button" id="gacv" value="getAllCheckedValue" onclick="fn()" />
</body>
</html>
</pre>
<p> 这是json数组:</p>
<pre name='code' class='xml'>[
{"text":"请选择","id":"all1","leaf":false,"checked":false,"depth":"0",
"children":[
{"text":"资产价值","id":"zichanjiazhi","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"100万以下","id":"100yixia","leaf":true,"checked":false,"depth":"2"},
{"text":"100万-500万","id":"100zhi500","leaf":true,"checked":false,"depth":"2"},
{"text":"500万-1000万","id":"500zhi1000","leaf":true,"checked":false,"depth":"2"},
{"text":"1000万以上","id":"1000yishang","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"资产类型","id":"zichanleixing","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"生产类","id":"shengchanlei","leaf":false,"checked":false,"depth":"2",
"children":[
{"text":"土地类","id":"tudilei","leaf":true,"checked":false,"depth":"3"},
{"text":"设备类","id":"shebeilei","leaf":true,"checked":false,"depth":"3"},
{"text":"建筑类","id":"jianzhulei","leaf":true,"checked":false,"depth":"3"}
]
},
{"text":"非生产类","id":"feishengchanlei","leaf":false,"checked":false,"depth":"2",
"children":[
{"text":"土地类","id":"feitudilei","leaf":true,"checked":false,"depth":"3"},
{"text":"设备类","id":"feishebeilei","leaf":true,"checked":false,"depth":"3"},
{"text":"建筑类","id":"feijianzhulei","leaf":true,"checked":false,"depth":"3"}
]
}
]
},
{"text":"单位类型","id":"danweileixing","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"工业","id":"gongye","leaf":true,"checked":false,"depth":"2"},
{"text":"商业","id":"shangye","leaf":true,"checked":false,"depth":"2"},
{"text":"直属企业","id":"zhisuqiye","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"使用状态","id":"shiyongzhuangtai","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"在建","id":"zaijian","leaf":true,"checked":false,"depth":"2"},
{"text":"在用","id":"zaiyong","leaf":true,"checked":false,"depth":"2"},
{"text":"租出","id":"zuchu","leaf":true,"checked":false,"depth":"2"},
{"text":"调拨","id":"diaobo","leaf":true,"checked":false,"depth":"2"},
{"text":"闲置","id":"xianzhi","leaf":true,"checked":false,"depth":"2"},
{"text":"报废","id":"baofei","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"资产来源","id":"zichanlaiyuan","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"购买","id":"gongmai","leaf":true,"checked":false,"depth":"2"},
{"text":"项目","id":"xiangmu","leaf":true,"checked":false,"depth":"2"},
{"text":"融资","id":"rongzhi","leaf":true,"checked":false,"depth":"2"},
{"text":"租入","id":"zuru","leaf":true,"checked":false,"depth":"2"}
]
}
]
}
]
</pre>
<p> </p>
<p> </p>
</div>
</div>
<div class='quote_div'><br/>但是发现一个问题就是,当你将节点收拢的后,再展开节点,节点下的构选项无法保存,也就是说,child.ui.toggleCheck(checked);根本没有保存变化,我用的版本是2.0b</div>
<div class='quote_div'><br/></div>
<div class='quote_div'><br/></div>
<div class='quote_div'>你把<span>animate:false, 看看。就可以啦!<br/></span></div>
<div class='quote_div'>
<div class='quote_title'>smellcode 写道</div>
<div class='quote_div'>
<div class='quote_title'>引用</div>
<div class='quote_div'>mercuryzhang:看你给的连接,只指出了一个方法。不知道checkboxtree的实现和普通的tree的实现有啥区别,能不能把这个发出来看看啊</div>
你其实可以用最简单的树来实现,不用什么extend<br/>
<pre name='code' class='html'><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Reorder TreePanel</title>
<link rel="stylesheet" type="text/css" href="../../../support/resources/css/ext-all.css" />
<script type="text/javascript" src="../../../support/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../../support/js/ext-all-debug.js"></script>
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = "../../../support/resources/images/default/s.gif"
var tree = null;
Ext.onReady(function(){
// shorthand
var Tree = Ext.tree;
tree = new Tree.TreePanel({
el:'tree-div',
autoScroll:true,
animate:true,
enableDD:true,
containerScroll: true,
loader: new Tree.TreeLoader({
dataUrl:'xmmapjson.json'
}),
rootVisible: false
});
tree.on('checkchange', function(node, checked) {
node.expand();
node.attributes.checked = checked;
node.eachChild(function(child) {
child.ui.toggleCheck(checked);
child.attributes.checked = checked;
child.fireEvent('checkchange', child, checked);
});
}, tree);
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'root',
draggable:false,
id:'root'
});
tree.setRootNode(root);
// render the tree
tree.render();
root.expand();
});
var fn = function() {
alert(tree.getChecked('id'));
};
</script>
</head>
<body scroll="no">
<b>Checked Nodes: </b> <input type="text" id="cn" value="" size="40" autocomplete="off" /><br />
<div id="tree-div" style="overflow:auto; height:300px;width:300px;border:1px solid #c3daf9;"></div>
<input type="button" id="gacv" value="getAllCheckedValue" onclick="fn()" />
</body>
</html>
</pre>
<p> 这是json数组:</p>
<pre name='code' class='xml'>[
{"text":"请选择","id":"all1","leaf":false,"checked":false,"depth":"0",
"children":[
{"text":"资产价值","id":"zichanjiazhi","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"100万以下","id":"100yixia","leaf":true,"checked":false,"depth":"2"},
{"text":"100万-500万","id":"100zhi500","leaf":true,"checked":false,"depth":"2"},
{"text":"500万-1000万","id":"500zhi1000","leaf":true,"checked":false,"depth":"2"},
{"text":"1000万以上","id":"1000yishang","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"资产类型","id":"zichanleixing","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"生产类","id":"shengchanlei","leaf":false,"checked":false,"depth":"2",
"children":[
{"text":"土地类","id":"tudilei","leaf":true,"checked":false,"depth":"3"},
{"text":"设备类","id":"shebeilei","leaf":true,"checked":false,"depth":"3"},
{"text":"建筑类","id":"jianzhulei","leaf":true,"checked":false,"depth":"3"}
]
},
{"text":"非生产类","id":"feishengchanlei","leaf":false,"checked":false,"depth":"2",
"children":[
{"text":"土地类","id":"feitudilei","leaf":true,"checked":false,"depth":"3"},
{"text":"设备类","id":"feishebeilei","leaf":true,"checked":false,"depth":"3"},
{"text":"建筑类","id":"feijianzhulei","leaf":true,"checked":false,"depth":"3"}
]
}
]
},
{"text":"单位类型","id":"danweileixing","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"工业","id":"gongye","leaf":true,"checked":false,"depth":"2"},
{"text":"商业","id":"shangye","leaf":true,"checked":false,"depth":"2"},
{"text":"直属企业","id":"zhisuqiye","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"使用状态","id":"shiyongzhuangtai","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"在建","id":"zaijian","leaf":true,"checked":false,"depth":"2"},
{"text":"在用","id":"zaiyong","leaf":true,"checked":false,"depth":"2"},
{"text":"租出","id":"zuchu","leaf":true,"checked":false,"depth":"2"},
{"text":"调拨","id":"diaobo","leaf":true,"checked":false,"depth":"2"},
{"text":"闲置","id":"xianzhi","leaf":true,"checked":false,"depth":"2"},
{"text":"报废","id":"baofei","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"资产来源","id":"zichanlaiyuan","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"购买","id":"gongmai","leaf":true,"checked":false,"depth":"2"},
{"text":"项目","id":"xiangmu","leaf":true,"checked":false,"depth":"2"},
{"text":"融资","id":"rongzhi","leaf":true,"checked":false,"depth":"2"},
{"text":"租入","id":"zuru","leaf":true,"checked":false,"depth":"2"}
]
}
]
}
]
</pre>
<p> </p>
<p> </p>
</div>
</div>
<div class='quote_div'><br/>但是发现一个问题就是,当你将节点收拢的后,再展开节点,节点下的构选项无法保存,也就是说,child.ui.toggleCheck(checked);根本没有保存变化,我用的版本是2.0b</div>
<div class='quote_div'><br/></div>
<div class='quote_div'><br/></div>
<div class='quote_div'>你把<span>animate:false, 看看。就可以啦!<br/></span></div>
6 楼
aiwobucuo
2008-06-28
你的JSON数据组是怎么样生成的啊
5 楼
c_mingze@163.com
2008-06-15
我也写了一个复选框的树
但是我想 知道怎么实现、特定情况下把页面变成灰色 就是不可以对chenked 或是当前这棵树进行操作。
但是我想 知道怎么实现、特定情况下把页面变成灰色 就是不可以对chenked 或是当前这棵树进行操作。
4 楼
小蚯蚓
2008-03-19
<div class='quote_title'>smellcode 写道</div><div class='quote_div'><div class='quote_title'>引用</div><div class='quote_div'>mercuryzhang:看你给的连接,只指出了一个方法。不知道checkboxtree的实现和普通的tree的实现有啥区别,能不能把这个发出来看看啊</div>你其实可以用最简单的树来实现,不用什么extend<br/><pre name='code' class='html'><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Reorder TreePanel</title>
<link rel="stylesheet" type="text/css" href="../../../support/resources/css/ext-all.css" />
<script type="text/javascript" src="../../../support/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../../support/js/ext-all-debug.js"></script>
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = "../../../support/resources/images/default/s.gif"
var tree = null;
Ext.onReady(function(){
// shorthand
var Tree = Ext.tree;
tree = new Tree.TreePanel({
el:'tree-div',
autoScroll:true,
animate:true,
enableDD:true,
containerScroll: true,
loader: new Tree.TreeLoader({
dataUrl:'xmmapjson.json'
}),
rootVisible: false
});
tree.on('checkchange', function(node, checked) {
node.expand();
node.attributes.checked = checked;
node.eachChild(function(child) {
child.ui.toggleCheck(checked);
child.attributes.checked = checked;
child.fireEvent('checkchange', child, checked);
});
}, tree);
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'root',
draggable:false,
id:'root'
});
tree.setRootNode(root);
// render the tree
tree.render();
root.expand();
});
var fn = function() {
alert(tree.getChecked('id'));
};
</script>
</head>
<body scroll="no">
<b>Checked Nodes: </b> <input type="text" id="cn" value="" size="40" autocomplete="off" /><br />
<div id="tree-div" style="overflow:auto; height:300px;width:300px;border:1px solid #c3daf9;"></div>
<input type="button" id="gacv" value="getAllCheckedValue" onclick="fn()" />
</body>
</html>
</pre><p> 这是json数组:</p><pre name='code' class='xml'>[
{"text":"请选择","id":"all1","leaf":false,"checked":false,"depth":"0",
"children":[
{"text":"资产价值","id":"zichanjiazhi","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"100万以下","id":"100yixia","leaf":true,"checked":false,"depth":"2"},
{"text":"100万-500万","id":"100zhi500","leaf":true,"checked":false,"depth":"2"},
{"text":"500万-1000万","id":"500zhi1000","leaf":true,"checked":false,"depth":"2"},
{"text":"1000万以上","id":"1000yishang","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"资产类型","id":"zichanleixing","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"生产类","id":"shengchanlei","leaf":false,"checked":false,"depth":"2",
"children":[
{"text":"土地类","id":"tudilei","leaf":true,"checked":false,"depth":"3"},
{"text":"设备类","id":"shebeilei","leaf":true,"checked":false,"depth":"3"},
{"text":"建筑类","id":"jianzhulei","leaf":true,"checked":false,"depth":"3"}
]
},
{"text":"非生产类","id":"feishengchanlei","leaf":false,"checked":false,"depth":"2",
"children":[
{"text":"土地类","id":"feitudilei","leaf":true,"checked":false,"depth":"3"},
{"text":"设备类","id":"feishebeilei","leaf":true,"checked":false,"depth":"3"},
{"text":"建筑类","id":"feijianzhulei","leaf":true,"checked":false,"depth":"3"}
]
}
]
},
{"text":"单位类型","id":"danweileixing","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"工业","id":"gongye","leaf":true,"checked":false,"depth":"2"},
{"text":"商业","id":"shangye","leaf":true,"checked":false,"depth":"2"},
{"text":"直属企业","id":"zhisuqiye","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"使用状态","id":"shiyongzhuangtai","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"在建","id":"zaijian","leaf":true,"checked":false,"depth":"2"},
{"text":"在用","id":"zaiyong","leaf":true,"checked":false,"depth":"2"},
{"text":"租出","id":"zuchu","leaf":true,"checked":false,"depth":"2"},
{"text":"调拨","id":"diaobo","leaf":true,"checked":false,"depth":"2"},
{"text":"闲置","id":"xianzhi","leaf":true,"checked":false,"depth":"2"},
{"text":"报废","id":"baofei","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"资产来源","id":"zichanlaiyuan","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"购买","id":"gongmai","leaf":true,"checked":false,"depth":"2"},
{"text":"项目","id":"xiangmu","leaf":true,"checked":false,"depth":"2"},
{"text":"融资","id":"rongzhi","leaf":true,"checked":false,"depth":"2"},
{"text":"租入","id":"zuru","leaf":true,"checked":false,"depth":"2"}
]
}
]
}
]
</pre> <p> </p><p> </p></div><br/>但是发现一个问题就是,当你将节点收拢的后,再展开节点,节点下的构选项无法保存,也就是说,child.ui.toggleCheck(checked);根本没有保存变化,我用的版本是2.0b
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Reorder TreePanel</title>
<link rel="stylesheet" type="text/css" href="../../../support/resources/css/ext-all.css" />
<script type="text/javascript" src="../../../support/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../../support/js/ext-all-debug.js"></script>
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = "../../../support/resources/images/default/s.gif"
var tree = null;
Ext.onReady(function(){
// shorthand
var Tree = Ext.tree;
tree = new Tree.TreePanel({
el:'tree-div',
autoScroll:true,
animate:true,
enableDD:true,
containerScroll: true,
loader: new Tree.TreeLoader({
dataUrl:'xmmapjson.json'
}),
rootVisible: false
});
tree.on('checkchange', function(node, checked) {
node.expand();
node.attributes.checked = checked;
node.eachChild(function(child) {
child.ui.toggleCheck(checked);
child.attributes.checked = checked;
child.fireEvent('checkchange', child, checked);
});
}, tree);
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'root',
draggable:false,
id:'root'
});
tree.setRootNode(root);
// render the tree
tree.render();
root.expand();
});
var fn = function() {
alert(tree.getChecked('id'));
};
</script>
</head>
<body scroll="no">
<b>Checked Nodes: </b> <input type="text" id="cn" value="" size="40" autocomplete="off" /><br />
<div id="tree-div" style="overflow:auto; height:300px;width:300px;border:1px solid #c3daf9;"></div>
<input type="button" id="gacv" value="getAllCheckedValue" onclick="fn()" />
</body>
</html>
</pre><p> 这是json数组:</p><pre name='code' class='xml'>[
{"text":"请选择","id":"all1","leaf":false,"checked":false,"depth":"0",
"children":[
{"text":"资产价值","id":"zichanjiazhi","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"100万以下","id":"100yixia","leaf":true,"checked":false,"depth":"2"},
{"text":"100万-500万","id":"100zhi500","leaf":true,"checked":false,"depth":"2"},
{"text":"500万-1000万","id":"500zhi1000","leaf":true,"checked":false,"depth":"2"},
{"text":"1000万以上","id":"1000yishang","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"资产类型","id":"zichanleixing","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"生产类","id":"shengchanlei","leaf":false,"checked":false,"depth":"2",
"children":[
{"text":"土地类","id":"tudilei","leaf":true,"checked":false,"depth":"3"},
{"text":"设备类","id":"shebeilei","leaf":true,"checked":false,"depth":"3"},
{"text":"建筑类","id":"jianzhulei","leaf":true,"checked":false,"depth":"3"}
]
},
{"text":"非生产类","id":"feishengchanlei","leaf":false,"checked":false,"depth":"2",
"children":[
{"text":"土地类","id":"feitudilei","leaf":true,"checked":false,"depth":"3"},
{"text":"设备类","id":"feishebeilei","leaf":true,"checked":false,"depth":"3"},
{"text":"建筑类","id":"feijianzhulei","leaf":true,"checked":false,"depth":"3"}
]
}
]
},
{"text":"单位类型","id":"danweileixing","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"工业","id":"gongye","leaf":true,"checked":false,"depth":"2"},
{"text":"商业","id":"shangye","leaf":true,"checked":false,"depth":"2"},
{"text":"直属企业","id":"zhisuqiye","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"使用状态","id":"shiyongzhuangtai","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"在建","id":"zaijian","leaf":true,"checked":false,"depth":"2"},
{"text":"在用","id":"zaiyong","leaf":true,"checked":false,"depth":"2"},
{"text":"租出","id":"zuchu","leaf":true,"checked":false,"depth":"2"},
{"text":"调拨","id":"diaobo","leaf":true,"checked":false,"depth":"2"},
{"text":"闲置","id":"xianzhi","leaf":true,"checked":false,"depth":"2"},
{"text":"报废","id":"baofei","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"资产来源","id":"zichanlaiyuan","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"购买","id":"gongmai","leaf":true,"checked":false,"depth":"2"},
{"text":"项目","id":"xiangmu","leaf":true,"checked":false,"depth":"2"},
{"text":"融资","id":"rongzhi","leaf":true,"checked":false,"depth":"2"},
{"text":"租入","id":"zuru","leaf":true,"checked":false,"depth":"2"}
]
}
]
}
]
</pre> <p> </p><p> </p></div><br/>但是发现一个问题就是,当你将节点收拢的后,再展开节点,节点下的构选项无法保存,也就是说,child.ui.toggleCheck(checked);根本没有保存变化,我用的版本是2.0b
3 楼
smellcode
2008-02-23
<div class='quote_title'>引用</div><div class='quote_div'>mercuryzhang:看你给的连接,只指出了一个方法。不知道checkboxtree的实现和普通的tree的实现有啥区别,能不能把这个发出来看看啊</div>你其实可以用最简单的树来实现,不用什么extend<br/><pre name='code' class='html'><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Reorder TreePanel</title>
<link rel="stylesheet" type="text/css" href="../../../support/resources/css/ext-all.css" />
<script type="text/javascript" src="../../../support/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../../support/js/ext-all-debug.js"></script>
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = "../../../support/resources/images/default/s.gif"
var tree = null;
Ext.onReady(function(){
// shorthand
var Tree = Ext.tree;
tree = new Tree.TreePanel({
el:'tree-div',
autoScroll:true,
animate:true,
enableDD:true,
containerScroll: true,
loader: new Tree.TreeLoader({
dataUrl:'xmmapjson.json'
}),
rootVisible: false
});
tree.on('checkchange', function(node, checked) {
node.expand();
node.attributes.checked = checked;
node.eachChild(function(child) {
child.ui.toggleCheck(checked);
child.attributes.checked = checked;
child.fireEvent('checkchange', child, checked);
});
}, tree);
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'root',
draggable:false,
id:'root'
});
tree.setRootNode(root);
// render the tree
tree.render();
root.expand();
});
var fn = function() {
alert(tree.getChecked('id'));
};
</script>
</head>
<body scroll="no">
<b>Checked Nodes: </b> <input type="text" id="cn" value="" size="40" autocomplete="off" /><br />
<div id="tree-div" style="overflow:auto; height:300px;width:300px;border:1px solid #c3daf9;"></div>
<input type="button" id="gacv" value="getAllCheckedValue" onclick="fn()" />
</body>
</html>
</pre><p> 这是json数组:</p><pre name='code' class='xml'>[
{"text":"请选择","id":"all1","leaf":false,"checked":false,"depth":"0",
"children":[
{"text":"资产价值","id":"zichanjiazhi","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"100万以下","id":"100yixia","leaf":true,"checked":false,"depth":"2"},
{"text":"100万-500万","id":"100zhi500","leaf":true,"checked":false,"depth":"2"},
{"text":"500万-1000万","id":"500zhi1000","leaf":true,"checked":false,"depth":"2"},
{"text":"1000万以上","id":"1000yishang","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"资产类型","id":"zichanleixing","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"生产类","id":"shengchanlei","leaf":false,"checked":false,"depth":"2",
"children":[
{"text":"土地类","id":"tudilei","leaf":true,"checked":false,"depth":"3"},
{"text":"设备类","id":"shebeilei","leaf":true,"checked":false,"depth":"3"},
{"text":"建筑类","id":"jianzhulei","leaf":true,"checked":false,"depth":"3"}
]
},
{"text":"非生产类","id":"feishengchanlei","leaf":false,"checked":false,"depth":"2",
"children":[
{"text":"土地类","id":"feitudilei","leaf":true,"checked":false,"depth":"3"},
{"text":"设备类","id":"feishebeilei","leaf":true,"checked":false,"depth":"3"},
{"text":"建筑类","id":"feijianzhulei","leaf":true,"checked":false,"depth":"3"}
]
}
]
},
{"text":"单位类型","id":"danweileixing","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"工业","id":"gongye","leaf":true,"checked":false,"depth":"2"},
{"text":"商业","id":"shangye","leaf":true,"checked":false,"depth":"2"},
{"text":"直属企业","id":"zhisuqiye","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"使用状态","id":"shiyongzhuangtai","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"在建","id":"zaijian","leaf":true,"checked":false,"depth":"2"},
{"text":"在用","id":"zaiyong","leaf":true,"checked":false,"depth":"2"},
{"text":"租出","id":"zuchu","leaf":true,"checked":false,"depth":"2"},
{"text":"调拨","id":"diaobo","leaf":true,"checked":false,"depth":"2"},
{"text":"闲置","id":"xianzhi","leaf":true,"checked":false,"depth":"2"},
{"text":"报废","id":"baofei","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"资产来源","id":"zichanlaiyuan","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"购买","id":"gongmai","leaf":true,"checked":false,"depth":"2"},
{"text":"项目","id":"xiangmu","leaf":true,"checked":false,"depth":"2"},
{"text":"融资","id":"rongzhi","leaf":true,"checked":false,"depth":"2"},
{"text":"租入","id":"zuru","leaf":true,"checked":false,"depth":"2"}
]
}
]
}
]
</pre> <p> </p><p> </p>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Reorder TreePanel</title>
<link rel="stylesheet" type="text/css" href="../../../support/resources/css/ext-all.css" />
<script type="text/javascript" src="../../../support/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../../support/js/ext-all-debug.js"></script>
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = "../../../support/resources/images/default/s.gif"
var tree = null;
Ext.onReady(function(){
// shorthand
var Tree = Ext.tree;
tree = new Tree.TreePanel({
el:'tree-div',
autoScroll:true,
animate:true,
enableDD:true,
containerScroll: true,
loader: new Tree.TreeLoader({
dataUrl:'xmmapjson.json'
}),
rootVisible: false
});
tree.on('checkchange', function(node, checked) {
node.expand();
node.attributes.checked = checked;
node.eachChild(function(child) {
child.ui.toggleCheck(checked);
child.attributes.checked = checked;
child.fireEvent('checkchange', child, checked);
});
}, tree);
// set the root node
var root = new Tree.AsyncTreeNode({
text: 'root',
draggable:false,
id:'root'
});
tree.setRootNode(root);
// render the tree
tree.render();
root.expand();
});
var fn = function() {
alert(tree.getChecked('id'));
};
</script>
</head>
<body scroll="no">
<b>Checked Nodes: </b> <input type="text" id="cn" value="" size="40" autocomplete="off" /><br />
<div id="tree-div" style="overflow:auto; height:300px;width:300px;border:1px solid #c3daf9;"></div>
<input type="button" id="gacv" value="getAllCheckedValue" onclick="fn()" />
</body>
</html>
</pre><p> 这是json数组:</p><pre name='code' class='xml'>[
{"text":"请选择","id":"all1","leaf":false,"checked":false,"depth":"0",
"children":[
{"text":"资产价值","id":"zichanjiazhi","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"100万以下","id":"100yixia","leaf":true,"checked":false,"depth":"2"},
{"text":"100万-500万","id":"100zhi500","leaf":true,"checked":false,"depth":"2"},
{"text":"500万-1000万","id":"500zhi1000","leaf":true,"checked":false,"depth":"2"},
{"text":"1000万以上","id":"1000yishang","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"资产类型","id":"zichanleixing","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"生产类","id":"shengchanlei","leaf":false,"checked":false,"depth":"2",
"children":[
{"text":"土地类","id":"tudilei","leaf":true,"checked":false,"depth":"3"},
{"text":"设备类","id":"shebeilei","leaf":true,"checked":false,"depth":"3"},
{"text":"建筑类","id":"jianzhulei","leaf":true,"checked":false,"depth":"3"}
]
},
{"text":"非生产类","id":"feishengchanlei","leaf":false,"checked":false,"depth":"2",
"children":[
{"text":"土地类","id":"feitudilei","leaf":true,"checked":false,"depth":"3"},
{"text":"设备类","id":"feishebeilei","leaf":true,"checked":false,"depth":"3"},
{"text":"建筑类","id":"feijianzhulei","leaf":true,"checked":false,"depth":"3"}
]
}
]
},
{"text":"单位类型","id":"danweileixing","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"工业","id":"gongye","leaf":true,"checked":false,"depth":"2"},
{"text":"商业","id":"shangye","leaf":true,"checked":false,"depth":"2"},
{"text":"直属企业","id":"zhisuqiye","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"使用状态","id":"shiyongzhuangtai","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"在建","id":"zaijian","leaf":true,"checked":false,"depth":"2"},
{"text":"在用","id":"zaiyong","leaf":true,"checked":false,"depth":"2"},
{"text":"租出","id":"zuchu","leaf":true,"checked":false,"depth":"2"},
{"text":"调拨","id":"diaobo","leaf":true,"checked":false,"depth":"2"},
{"text":"闲置","id":"xianzhi","leaf":true,"checked":false,"depth":"2"},
{"text":"报废","id":"baofei","leaf":true,"checked":false,"depth":"2"}
]
},
{"text":"资产来源","id":"zichanlaiyuan","leaf":false,"checked":false,"depth":"1",
"children":[
{"text":"购买","id":"gongmai","leaf":true,"checked":false,"depth":"2"},
{"text":"项目","id":"xiangmu","leaf":true,"checked":false,"depth":"2"},
{"text":"融资","id":"rongzhi","leaf":true,"checked":false,"depth":"2"},
{"text":"租入","id":"zuru","leaf":true,"checked":false,"depth":"2"}
]
}
]
}
]
</pre> <p> </p><p> </p>
2 楼
mercuryzhang
2008-02-22
看不懂啊,能不能把整个tree地实现给出来啊。谢谢
1 楼
kaki
2008-02-20
node.eachChild(function(child) { child.ui.toggleCheck(checked); child.attributes.checked = checked; child.fireEvent('checkchange', child, checked); });
感谢分享,这一句很关键!
相关推荐
9.2. 带全选的checkbox树形CheckBoxTree 9.3. 带全选的checkbox的grid 9.4. fisheye 9.5. 可以设置时间的日期控件 9.6. JsonView实现用户卡片拖拽与右键菜单 9.7. 下拉列表选择每页显示多少数据 10. 撕裂吧!...
自动生成行号,支持checkbox全选,动态选择显示哪些列,支持本地以及远程分页,可以对单元格按照自己的想法进行渲染,这些也算可以想到的功能。 再加上可编辑grid,添加新行,删除一或多行,提示脏数据,推拽...
例如,TreeField和CheckBoxTree等控件都是扩展自标准组件的功能。此外,Ext JS还可以与其他技术(如dwr、localXHR等)整合,增加更多的功能和灵活性。 #### 9. 常见问题解答 在Ext使用过程中,可能遇到各种问题,...
9.2. 带全选的checkbox树形CheckBoxTree 9.3. 带全选的checkbox的grid 9.4. fisheye 9.5. 可以设置时间的日期控件 9.6. JsonView实现用户卡片拖拽与右键菜单 9.7. 下拉列表选择每页显示多少数据 10. 撕裂吧!...
9.2. 带全选的checkbox树形CheckBoxTree 9.3. 带全选的checkbox的grid A. 常见问题乱弹 A.1. 怎么查看ext2里的api文档 A.2. 想把弹出对话框单独拿出来用的看这里 A.3. 想把日期选择框单独拿出来用的看这里 ...
呵呵~不过ext也不是万能的,与fins的ecside比较,ext不能锁定列(土豆说1.x里支持锁定列,但是2.0里没有了,因为影响效率。),也没有默认的统计功能,也不支持excel,pdf等导出数据。另外fins说,通过测试ecside...
注:ExtAspNet基于一些开源的程序ExtJS, HtmlAgilityPack, Nii.JSON, YUICompressor。 示例: http://extasp.net/ 开源: http://extaspnet.codeplex.com/ 博客: http://sanshi.cnblogs.com/ 邮箱: sanshi.ustc@gmail...
自动生成行号,支持checkbox全选,动态选择显示哪些列,支持本地以及远程分页,可以对单元格按照自己的想法进行渲染,这些也算可以想到的功能。 再加上可编辑grid,添加新行,删除一或多行,提示多行数据,拖拽改变...
EXTJS是一种基于JavaScript的UI框架,它源自JAVASCRIPT,致力于提供丰富的Web2.0用户体验。EXTJS的核心特点是利用CSS来控制DIV元素,从而创建出具有高度交互性和良好视觉效果的网页应用。EXTJS充分利用AJAX技术,...
支持的浏览器: IE 7.0+, Firefox 3.0+, Chrome 2.0+, Opera 9.5+, Safari 3.0+ 注:ExtAspNet基于一些开源的程序ExtJS, HtmlAgilityPack, Nii.JSON, YUICompressor。 示例: http://extasp.net/ 开源: ...