Extjs

 var productCategoryTreeLookUpFn = function(callback) {
var productCategoryLookUpWindow;
var productCategoryTreeStore;
var productCategoryTreeMenu; if (!productCategoryLookUpWindow) { // 加载菜单树
productCategoryTreeStore = Ext.create('Ext.data.TreeStore', {
fields : ['id', 'text'],
proxy: {
type: 'ajax',
url: COMMON.APP_URL + '/view/master/selectProductCategoryForComboBoxTree.action'
},
root: {
id: '0',
text : "产品分类",
expanded: true
}
}); var beforNode = null;
productCategoryTreeMenu = Ext.create('Ext.tree.Panel', {
store: productCategoryTreeStore,
rootVisible : false,
height : 300,
animate : true, // 开启动画效果
enableDD : false, // 不允许子节点拖动
border : false, // 没有边框
singleClickExpand : true,
listeners : {
checkchange : function(node, checked, eOpts) {
// setChildChecked(node, checked);
if(node.isNode){
if(beforNode != null){//把上一次选中节点取消选择,实现单选
beforNode.set("checked",false);
}
beforNode = node;
// node.collapse();
// node.cascadeBy(function(node) {
// node.set("checked",checked);
// });
}
}
}
}); function setChildChecked(node, checked){
node.set({checked:checked});
if(node.hasChildNodes()){
node.eachChild(function(child) {
setChildChecked(child, checked);
});
}
} function setParentChecked(node, checked){
node.set({checked:checked});
var parentNode = node.parentNode;
if(parentNode != null){
var flag = false;
parentNode.eachChild(function(child) {
if(child.data.checked == true){
flag = true;
}
});
if (checked == false) {
if(!flag){
setParentChecked(parentNode, checked);
}
} else {
if(flag){
setParentChecked(parentNode, checked);
}
}
}
} productCategoryLookUpWindow = Ext.create('Ext.window.Window', {
title : '产品分类信息',
autoShow: true,
width : 400,
constrain : true,
constrainHeader : true,
maximizable : false,
minimizable : false,
resizable : false,
closable : false,
buttonAlign : 'right',
animateTarget: Ext.getBody(),
modal : true,
plain : true,
border : true,
closeAction : 'destroy',
items : [productCategoryTreeMenu],
buttons : [{
text : '确定',
handler : function() {
var checkNodeArray = productCategoryTreeMenu.getChecked();
var checkNodeString = '';
var checkNodeTextString = '';
for (var index = 0; index < checkNodeArray.length; index++) {
checkNodeString += checkNodeArray[0].data.id;
checkNodeTextString += checkNodeArray[0].data.qtip;
}
if (Ext.isFunction(callback)) {
callback(checkNodeString, checkNodeTextString);
}
productCategoryLookUpWindow.destroy();
}
}, {
text : '关闭',
handler : function() {
productCategoryLookUpWindow.destroy();
}
}]
}); } productCategoryLookUpWindow.show(); };

Java

for (ProductCategoryVO dbVo : productCategoryVOList) {
JSONObject obj = new JSONObject();
obj.put("id", dbVo.getCategoryIdFull());
obj.put("text", dbVo.getCategoryName());
obj.put("qtip", dbVo.getCategoryNameFull());
obj.put("leaf", !new Boolean(dbVo.getIsExistChildNode()));
obj.put("checked", new Boolean(false));
// obj.put("isExistChildNode", new Boolean(dbVo.getIsExistChildNode()));
// obj.put("categoryId", dbVo.getCategoryId());
// obj.put("categoryName", dbVo.getCategoryName());
// obj.put("categoryIdFull", dbVo.getCategoryIdFull());
// obj.put("categoryNameFull", dbVo.getCategoryNameFull());
// obj.put("parentIdFull", dbVo.getParentIdFull());
// obj.put("parentNameFull", dbVo.getParentNameFull());
// obj.put("recordId", dbVo.getId());
// obj.put("nodeLevel", dbVo.getNodeLevel());
jsonArray.add(obj);
}

Ext.tree.Panel实现单选,多选的更多相关文章

  1. Ext.tree.Panel Extjs 在表格中添加树结构,并实现节点移动功能

    最近在用Extjs 做后台管理系统,真的非常好用.总结的东西分享一下. 先展示一下效果图 好了,开始吧! 首先说一下我的创建结构: 一.构造内容 这个函数中包括store的创建,treePanel的创 ...

  2. Extjs学习笔记--Ext.tree.Panel

    Ext.create('Ext.tree.Panel', { title: 'Simple Tree', width: 200, height: 150, store: store, rootVisi ...

  3. Extjs4.x Ext.tree.Panel 过滤Filter以及trigger field的使用

    Extjs4.x中已经取消了组件Ext.Tree.TreeFilter功能,却掉了树形结构的过滤功能,要实现该功能只能自己写了. Tree节点筛选UI很简单,一个Tbar,一个trigger即可解决问 ...

  4. Extjs4.x Ext.tree.Panel 遍历当前节点下的所有子节点

    Ext.define('WMS.controller.Org', { extend: 'Ext.app.Controller', stores: ['OrgUser', 'OrgTree'], mod ...

  5. Ext.tree.Panel

    initComponent : function() { var data = null;        Ext.Ajax.request({            url : 'xxx/xx',   ...

  6. ExtJS 4 在Ext.tab.Panel中使用Ext.ux.IFrame打开url指向的网页

    ext-4.2.1.883\examples\ux\IFrame.js ext-4.2.1.883\examples\ux\TabCloseMenu.js 复制到 \Scripts\ext-4.2.1 ...

  7. Extjs-树 Ext.tree.TreePanel 动态加载数据

    先上效果图 1.说明Ext.tree.Panel 控件是树形控件,大家知道树形结构在软件开发过程中的应用是很广泛的,树形控件的数据有本地数据.服务器端返回的数据两种.对于本地数据的加载,在extjs的 ...

  8. Javascript - ExtJs - Ext.form.Panel组件

    FormPanel组件(Ext.form.FormPanel) logogram:Ext.form.Panel | xtype:form Ext.form.Panel.配置 frame }//旗下所有 ...

  9. Ext.tree.TreePanel 属性详解

    Ext.tree.TreePanel 属性详解 2013-06-09 11:02:47|  分类: ExtJs|举报|字号 订阅  原文地址:http://blog.163.com/zzf_fly/b ...

随机推荐

  1. Android RecyclerView notifyDataSetChanged不起作用

    一般listview设置完data后调用notifyDataSetChanged便可刷新布局界面,然而recycleview调用这个方法却没有任何反应.对于很多不熟悉recycleview的话很容易躺 ...

  2. Android彻底组件化方案实践

    本文提出的组件化方案demo已经开源,参见文章Android彻底组件化方案开源. 文末有罗辑思维"得到app"的招聘广告,欢迎各路牛人加入!! 一.模块化.组件化与插件化 项目发展 ...

  3. [转]STL之deque容器详解

    Deque 容器 deque容器是C++标准模版库(STL,Standard Template Library)中的部分内容.deque容器类与vector类似,支持随机访问和快速插入删除,它在容器中 ...

  4. canves应用

    canves用得好可以有好多效果: html:<canvas id="myCanvas" width="700" height="300&quo ...

  5. css3背景渐变色代码

    从上到下 #grad {  background: -webkit-linear-gradient(red, blue);  background: -o-linear-gradient(red, b ...

  6. C#——数据库的访问

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  7. [文章转载]-我的Java后端书架-江南白衣

    我的Java后端书架 (2016年暮春3.0版) 04月 24, 2016 | Filed under 技术 书架主要针对Java后端开发. 3.0版把一些后来买的.看的书添补进来,又或删掉或降级一些 ...

  8. java 类名.this

    类名为this的限定词. 相对于内部类:有多个this: 1.内部类本身的this: 2.内部类的环境类的this: 类名.this,就是为了对这些this指针的指向做出限定. 区别于类名.class ...

  9. QQ空间里写的开发心得

    不回头看一眼还真没发现我已经写过这么多开发心得日志. 理一理设备数据走向  https://user.qzone.qq.com/1156740846/blog/1522292793 action的生命 ...

  10. js中关于new Object时传参的一些细节分析

    1, 参数是一个对象,核心js对象(native ECMAScript object)或宿主对象(host object),那么将直接返回该对象. 其生成的对象构造器仍然是所传参数对象的构造器.这样造 ...