extjs_10_自己定义combotree组件
1.项目截图
2.treedata.json
{
text : "root",
expanded : true,
expandable : true,
children : [{
text : "Dept 1",
leaf : false,
expandable : true,
children : [{
text : "user1",
leaf : true
}, {
text : "user2",
leaf : true
}, {
text : "user3",
leaf : true
}]
}, {
text : "Dept 2",
leaf : false,
expandable : true,
children : [{
text : "user4",
leaf : true
}, {
text : "user5",
leaf : true
}, {
text : "user6",
leaf : true
}, {
text : "user7",
leaf : true
}, {
text : "user8",
leaf : true
}]
}]
}
3.ComboTree.js
Ext.define("Ext.ux.ComboTree", {
extend : "Ext.form.field.ComboBox",
alias : "widget.combotree",
url : "",
tree : {},
initComponent : function() {
// tpl下拉框显示内容 displayTpl文本框显示内容
this.treeid = Ext.String.format("combo-tree-{0}", Ext.id());
this.tpl = Ext.String.format("<div id={0}></div>", this.treeid);
if (this.url) {// 推断url是否配置
var me = this;
var treeStore = Ext.create("Ext.data.TreeStore", {
root : {
expanded : true
},// 默认展开
proxy : {
type : "ajax",
url : this.url
}
});
this.tree = Ext.create("Ext.tree.Panel", {
rootVisible : false,// 不显示根节点
autoScorll : true,
height : 200,
store : treeStore
});
this.tree.on("itemclick", function(combo, record) {// 监听tree的点击事件
if (me.fireEvent("select", me, record))// 有级联操作的时候要这样写(第一个combobox引发第二个combobox过滤)
{
me.setValue(record);
me.collapse();// 折叠节点
}
});
this.on("expand", function() {// 展开的时候渲染
this.tree.store.load();// 展开的时候又一次渲染数据。保证数据是最新的
if (!this.tree.rendered) {// 推断是否渲染
this.tree.render(this.treeid);// 渲染
}
});
// if(me.fireEvent("select",me,record)) 不写的时候不能监听select事件
this.on("select", function(combo, record) {
Ext.Msg.alert("Title", "you selected " + record.data.text);
})
}
this.callParent();
}
})
4.comboboxtree.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>自己定义分页组建</title>
<!-- 引入样式,能够把ext-all.css换成ext-all-access.css | ext-all-gray.css改变样式-->
<link rel="stylesheet" type="text/css" href="./extjs4.1/resources/css/ext-all.css">
<!-- 开发模式引入ext-all-debug.js。公布模式引入ext-all.js -->
<script type="text/javascript" src="./extjs4.1/ext-all-debug.js"></script>
<!-- 语言包 -->
<script type="text/javascript" src="./extjs4.1/locale/ext-lang-zh_CN.js"></script>
<!-- 引入自己定义分页 -->
<script type="text/javascript" src="./extjs4.1/ux/ComboTree.js"></script>
<script type="text/javascript">
Ext.onReady(function() {
Ext.Loader.setConfig({
paths : {
"Ext.ux" : "extjs4.1/ux"
}
});
Ext.create("Ext.ux.ComboTree", {
url : "extjs4.1/data/treedata.json",
valueField : "text",
displayField : "text",
queryMode : "local",
renderTo : Ext.getBody(),
fieldLabel : "ComboTree"
})
});
</script>
</head>
<body>
<br>
</body>
</html>
extjs_10_自己定义combotree组件的更多相关文章
- vue.2.0-自定义全局组件
App.vue <template> <div id="app"> <h3>welcome vue-loading</h3> < ...
- 第六章 组件 55 组件-使用components定义私有组件
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- TZ_16_Vue定义全局组件和局部组件
1.定义全局组件 我们通过Vue的component方法来定义一个全局组件. <div id="app"> <!--使用定义好的全局组件--> <co ...
- vue定义全局组件
<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>& ...
- Django-自定义分页组件
1.封装的分页代码: class PageInfo(object): def __init__(self,current_page,all_count,per_page,base_url,show_p ...
- 初学React:定义一个组件
接着聊React,今天说说如何创建一个组件类. <!DOCTYPE html> <html lang="en"> <head> <meta ...
- 使用模块定义AngularJS组件
一.模块创建/查找 module 当创建一个模块时,必须指定name和requires参数,即使你的模块并不存在依赖 var myApp=angular.module("exampleApp ...
- WeChat-SmallProgram:如何定义一个组件
创建组件所需的文件: 1.在根目录创建 Componet 文件夹 2.再创建一个select文件夹 3.然后:右键这个文件夹,新建下面的这个 Component.然后输入需要创建的名称,我这里为了方便 ...
- WinForm------自定义YearMonthEdit组件
转载: http://www.cnblogs.com/axing/p/3201066.html 注意: 1.需要在vs里面,添加一个YearMonthEdit组件,然后将链接里面的代码拷贝到里面 2. ...
随机推荐
- IOS 应用发布流程
发布流程总结成三个步骤: iOS应用发布流程(一)------相关app证书的申请.下载以及安装 http://blog.csdn.net/ys371277787/article/details/50 ...
- vue--vConsole
平时在web应用开发过程中,我们可以console.log去输出一些信息,但是在移动端,也就是在手机上,console.log的信息我们是看不到的. 这种情况下,可以选择使用alert弹出一些信息,但 ...
- mysql57 centos7 使用
####### yum repository install #######mysql yum repo http://repo.mysql.com/wget http://repo.mysql.co ...
- ARM内核版本号和SOC版本号
原博:https://blog.csdn.net/wxywxywxy110/article/details/78764988 内核版本号 SoC版本号 ...
- [Angular] 'providedIn' for service
There is now a new, recommended, way to register a provider, directly inside the @Injectable() decor ...
- python-html基础操作
介绍: HTML 是网页内容的载体.包括文字,图片,信息等用户浏览的信息CSS 样式是改变内容外观表现.像字体,颜色,背景,边框等JavaScript 是实现网页上的特效效果.如鼠标滑过背景 ...
- Django-2.1基础操作
创建项目 安装django pip3 install django #查看django版本 django-admin --version python -m django --version 2.1. ...
- httpd常见配置
httpd常见配置 配置文件 /etc/httpd/conf/httpd.conf 主配置文件 /etc/httpd/conf.d/*.conf 辅助配置文件 配置文件语法检查及重新加载配置文 ...
- Matlab:导数边界值的有限元(Ritz)法
tic; % this method is transform from Ritz method %is used for solving two point BVP %this code was w ...
- mysql中关于关联索引的问题——对a,b,c三个字段建立联合索引,那么查询时使用其中的2个作为查询条件,是否还会走索引?
情况描述:在MySQL的user表中,对a,b,c三个字段建立联合索引,那么查询时使用其中的2个作为查询条件,是否还会走索引? 根据查询字段的位置不同来决定,如查询a, a,b a,b, ...