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. [ BZOJ 3038 & 3211 / SPOJ GSS4 ] 上帝造题七分钟2 / 花神游历各国

    \(\\\) \(Description\) 给出一个长度为\(N\)的数列,共进行\(M\)次操作: \(1\ L\ R\):查询\([L,R]\)区间和. \(2\ L\ R\):对\([L,R] ...

  2. Android控件的继承关系

    1.View,ViewGroup >View: }1.所有高级UI组件都继承View类而实现的 }2.一个View在屏幕上占据一块矩形区域 }3. 负责渲染 }4.负责处理发生的事件 }5.设置 ...

  3. GatewayWorker + LayIM实现即时聊天

    一.程序目录结构 二.代码展示 附LayIM开发文档:https://www.layui.com/doc/modules/layim.html 1.前端代码 <!DOCTYPE html> ...

  4. 通过python xlsxwriter模块生成EXCEL柱状图、饼图

    xlsxwriter模块不是python自带的,使用pip下载 import xlsxwriter #新建一个excel文件,起名为expense01.xlsx workbook = xlsxwrit ...

  5. PHP控制反转(IOC)和依赖注入(DI

    <?php class A { public $b; public $c; public function A() { //TODO } public function Method() { $ ...

  6. Git环境部署

     部署git 服务器环境   系统环境准备 192.168.30.25   master     git   gitlab 192.168.30.26   client      git 关闭防火墙 ...

  7. BZOJ 2276: [Poi2011]Temperature 单调队列

    Code: #include<bits/stdc++.h> #define maxn 3000000 using namespace std; void setIO(string s) { ...

  8. 2 Button

    // <summary> /// 设置透明按钮样式 /// </summary> private void SetBtnStyle(Button btn) { btn.Flat ...

  9. Qt Creator 中文乱码问题

    一. Qt 4 乱码问题 解决方案 1. 在Qt 中 快捷菜单选项功能中 Edit(编辑)  --> Select Encoding...(选择编码) 选择载入(显示)编码和储存编码,要解决中文 ...

  10. gcc和gdb的基本操作

    gcc和gdb yum 在线安装软件,使用阿里云镜像站,OPSX 选择你安装的系统 点帮助 查看配置命令行 yum --list | grep gdb #查找要安装的软件 yum install -y ...