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组件的更多相关文章

  1. vue.2.0-自定义全局组件

    App.vue <template> <div id="app"> <h3>welcome vue-loading</h3> < ...

  2. 第六章 组件 55 组件-使用components定义私有组件

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  3. TZ_16_Vue定义全局组件和局部组件

    1.定义全局组件 我们通过Vue的component方法来定义一个全局组件. <div id="app"> <!--使用定义好的全局组件--> <co ...

  4. vue定义全局组件

    <!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>& ...

  5. Django-自定义分页组件

    1.封装的分页代码: class PageInfo(object): def __init__(self,current_page,all_count,per_page,base_url,show_p ...

  6. 初学React:定义一个组件

    接着聊React,今天说说如何创建一个组件类. <!DOCTYPE html> <html lang="en"> <head> <meta ...

  7. 使用模块定义AngularJS组件

    一.模块创建/查找 module 当创建一个模块时,必须指定name和requires参数,即使你的模块并不存在依赖 var myApp=angular.module("exampleApp ...

  8. WeChat-SmallProgram:如何定义一个组件

    创建组件所需的文件: 1.在根目录创建 Componet 文件夹 2.再创建一个select文件夹 3.然后:右键这个文件夹,新建下面的这个 Component.然后输入需要创建的名称,我这里为了方便 ...

  9. WinForm------自定义YearMonthEdit组件

    转载: http://www.cnblogs.com/axing/p/3201066.html 注意: 1.需要在vs里面,添加一个YearMonthEdit组件,然后将链接里面的代码拷贝到里面 2. ...

随机推荐

  1. OpenGL.Tutorial16_ShadowMapping

    1. 2. In Tutorial 15 we learnt how to create lightmaps, which encompasses(包含) static lighting. While ...

  2. 聊聊Flume和Logstash的那些事儿

    在某个Logstash的场景下,我产生了为什么不能用Flume代替Logstash的疑问,因此查阅了不少材料在这里总结,大部分都是前人的工作经验下,加了一些我自己的思考在里面,希望对大家有帮助. 本文 ...

  3. VUE.js 简单引用

    Vue开发的两种方式:静态资源引入开发 和 脚手架交互式开发 这里使用的是静态资源引入开发 首先 引用jquery.js  和  vue.js html 标签内加个 <div id=" ...

  4. rsync详细配置

    1 说在前面的话 rsync官方网站: https://www.samba.org/ftp/rsync/rsync.html rsync是可以实现增量备份的工具.配合任务计划,rsync能实现定时或间 ...

  5. MongoDB一键安装

    #!/bin/bash export lang=Cecho '#1.关闭本地的MongoDB'#service mongodb stopecho '#2.清空本地MongoDB的安装文件'rm -rf ...

  6. .Net Core2.1 部署到IIS

    1. 发布网站,和.net framework MVC一样 2.安装WindowsHosting和.Net Core SDK 下载地址:https://www.microsoft.com/net/do ...

  7. C# 远程传输File文件

    /// <summary> /// 向论坛传图片文件 /// </summary> /// <param name="filePath">< ...

  8. 本地jar包安装到本地仓库

    将本地jar包安装到本地仓库中,记得参数上有双引号 mvn install:install-file -Dfile="jar全路径" -DgroupId="groupId ...

  9. HTTP的缓存策略

    etag 与 if-match https://www.cnblogs.com/huangzhilong/p/4999207.html https://juejin.im/post/5c136bd16 ...

  10. 基于FPGA的1553B通信模块的设计(转)

    reference:http://www.21ic.com/app/eda/201808/798483.htm https://www.milstd1553.com/ [导读] 摘 要: 提出一种将F ...