EXTJS下拉树ComboBoxTree参数提交及回显方法
http://blog.csdn.net/wjlht/article/details/6085245
使用extjs可以构造出下拉数,但是不方便向form提交参数,在此,笔者想到一个办法,很方便ComboBoxTree向form提交。
原理:
在form中增加一个隐藏的字段,当在comboBoxTree中选定值后自动在隐藏字段中赋值。
为实现此方法,需要重载comboBoxTree中collapse事件方法。
Ext.ux.ComboBoxTree = function(){
this.treeId = Ext.id()+'-tree';
this.maxHeight = arguments[0].maxHeight || arguments[0].height || this.maxHeight;
this.tpl = new Ext.Template('<tpl for="."><div style="height:'+this.maxHeight+'px"><div id="'+this.treeId+'"></div></div></tpl>');
this.store = new Ext.data.SimpleStore({fields:[],data:[[]]});
this.selectedClass = '';
this.mode = 'local';
this.triggerAction = 'all';
this.onSelect = Ext.emptyFn;
this.editable = false;
this.selectNodeModel = arguments[0].selectNodeModel || 'exceptRoot';
Ext.ux.ComboBoxTree.superclass.constructor.apply(this, arguments);
}
Ext.extend(Ext.ux.ComboBoxTree,Ext.form.ComboBox, {
expand : function(){
Ext.ux.ComboBoxTree.superclass.expand.call(this);
if(!this.tree.rendered){
this.tree.height = this.maxHeight;
this.tree.border=false;
this.tree.autoScroll=true;
if(this.tree.xtype){
this.tree = Ext.ComponentMgr.create(this.tree, this.tree.xtype);
}
this.tree.render(this.treeId);
var combox = this;
this.tree.on('click',function(node){
var isRoot = (node == combox.tree.getRootNode());
var selModel = combox.selectNodeModel;
var isLeaf = node.isLeaf();
if(isRoot && selModel != 'all'){
return;
}else if(selModel=='folder' && isLeaf){
return;
}else if(selModel=='leaf' && !isLeaf){
return;
}
combox.setValue(node);
combox.collapse();
});
var root = this.tree.getRootNode();
if(!root.isLoaded())
root.reload();
}
},
setValue : function(node){
var text = node.text;
this.lastSelectionText = text;
if(this.hiddenField){
this.hiddenField.value = node.id;
}
Ext.form.ComboBox.superclass.setValue.call(this, text);
this.value = node.id;
},
collapse:function(){
Ext.ux.ComboBoxTree.superclass.collapse.call(this);
document.getElementById("myhiddencomboboxtree").value = this.getRawValue();
},
getValue : function(){
return typeof this.value != 'undefined' ? this.value : '';
}
});
Ext.reg('combotree', Ext.ux.ComboBoxTree);
红色部分就是增加的重载代码,作用是当下拉数收起后,将id为myhiddencomboboxtree的隐藏字段赋值,在form中添加该隐藏字段就可以提交参数了。
添加该隐藏字段代码:
<input type="hidden" name="aaa" id="myhiddencomboboxtree" value='hello'/>
至于向comboBoxTree赋值,则在javascript中直接调用函数comboBoxTree.setValue(),例如:
comboBoxTree.setValue({id:'0',text:'新闻类型'})
至此,comboxTree的传值和回显就全部解决了,大家就可以在项目中使用comboBoxTree来显示下拉树了。对于在需要将类型或单位无限级划分的地方比较适用。
EXTJS下拉树ComboBoxTree参数提交及回显方法的更多相关文章
- Extjs下拉树代码测试总结
http://blog.csdn.net/kunoy/article/details/8067801 首先主要代码源自网络,对那些无私的奉献者表示感谢! 笔者对这些代码做了二次修改,并总结如下: Ex ...
- layui下拉框渲染问题,以及回显问题
最近实习公司给的新人练手项目用的layui,layui之前自己也接触过但是也就是用了用table组件,没有用过layer弹层这些东西,所以就了解了一下. 首先遇到的一个问题就是下拉框没有样式,然后加样 ...
- vue 模拟下拉树
// 使用vue 做表格部分其他部分暂不修改 var app = new Vue({ el: "#freightTbl", watch: { //监听表格数据的变化[使用 watc ...
- zTree开发下拉树
最近,因为工作需要一个树形下拉框的组件,经过查资料一般有两种的实现方法.其一,就是使用zTree实现:其二,就是使用easyUI实现.因为公司的前端不是使用easyUI设计的,故这里我选择了zTree ...
- 开源框架.netCore DncZeus学习(五)下拉树的实现
千里之行,始于足下,先从一个小功能研究起,在菜单管理页面有一个下拉树,先研究下它怎么实现的 1.先找到menu.vue页面 惯性思维先搜索请选择三个字,原来是动态生成的 再向上找DropDown组件, ...
- vue-Treeselect实现组织机构(员工)下拉树的功能
知识点:前端使用vuetree的组件库,调用后台查询组织机构,包括人员的接口 实现下拉树的功能 查考: vue-treeselect官网:https://vue-treeselect.js.org/ ...
- layui扩展组件,下拉树多选
项目介绍 项目中需要用到下拉树多选功能,找到两个相关组件moretop-layui-select-ext和wujiawei0926-treeselect,但是moretop-layui-selec ...
- vue+element下拉树选择器
项目需求:输入框点击弹出树形下拉结构,可多选或者单选. 解决方案:1.使用layui formSelect多选插件 2.基于vue+elementui 下拉框和树形控件组合成树形下拉结构 <el ...
- EasyUI-combotree 下拉树 数据回显时默认选中
组合树(combotree)把选择控件和下拉树结合起来.它与组合框(combobox)相似,不同的是把列表替换成树组件.组合树(combotree)支持带有用于多选的树状态复选框的树. 依赖 comb ...
随机推荐
- Battery Charging Specification 1.2 中文详解 来源:www.chengxuyuans.com
1. Introduction 1.1 Scope 规范定义了设备通过USB端口充电的检测.控制和报告机制,这些机制是USB2.0规范的扩展,用于专用 充电器(DCP).主机(SDP).hub(SDP ...
- 配置kernel的log buf大小(如果kmsg log被覆盖)
如果在打印kmsg log时发现log被覆盖,log 的buf不够大可以使用默认配置调buf: defconfig CONFIG_LOG_BUF_SHIFT=20 (默认是17 2的17次方) ...
- java实现ftp文件上传下载,解决慢,中文乱码,多个文件下载等问题
//文件上传 public static boolean uploadToFTP(String url,int port,String username,String password,String ...
- The hub and spoke model 轮辐模型/辐射模型
最近一些文档中提到The Hub and Spoke Model,这里mark一下.hub表示轮毂,spoke表示轮辐,轮辐模型是简化网络路由的一套中心化的体系,广泛应用于航空.货运.快递以及网络技术 ...
- Idea安装Scala插件(转)
原文链接:http://blog.csdn.net/a2011480169/article/details/52712421 参考博客: 1.http://wwwlouxuemingcom.blog. ...
- HDU 3342 Legal or Not(拓扑排序判断成环)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3342 题目大意:n个点,m条有向边,让你判断是否有环. 解题思路:裸题,用dfs版的拓扑排序直接套用即 ...
- Asp.Net MVC4 之Url路由
先来看下面两个个url,对比一下: http://xxx.yyy.com/Admin/UserManager.aspx http://xxx.yyy.com/Admin/DeleteUser/1001 ...
- Dockerfile 备份
dotnet core app FROM microsoft/dotnet:1.1.0-runtime WORKDIR /mvcApp COPY ./out . ENTRYPOINT ["d ...
- vscode vue配置和一些其它辅助【工具篇】
后续有补充就经常更新
- <c:if></c:if>用法-转载
<c:if test="value ne, eq, lt, gt,...."> 用法 类别 运算符 算术运算符 + . - . * . / (或 div )和 % (或 ...