Extjs_10 _ custom combotree component, extjs_10combotree

Source: Internet
Author: User

Extjs_10 _ custom combotree component, extjs_10combotree
1. Project

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 () {// The content displayed in the displayTpl text box in the tpl drop-down box this. treeid = Ext. string. format ("combo-tree-{0}", Ext. id (); this. tpl = Ext. string. format ("<div id = {0}> </div>", this. treeid); if (this. url) {// determine whether the url is configured with var me = this; var treeStore = Ext. create ("Ext. data. treeStore ", {root: {expand Ed: true}, // expand proxy: {type: "ajax", url: this. url}); this. tree = Ext. create ("Ext. tree. panel ", {rootVisible: false, // do not display the root node autoScorll: true, height: 200, store: treeStore}); this. tree. on ("itemclick", function (combo, record) {// listen to the tree click event if (me. fireEvent ("select", me, record) // This is the case when cascade operations are performed (the first combobox triggers the second combobox filter) {me. setValue (record); me. collapse (); // collapse node}); this. on ("expand", function () {// Render this. tree. store. load () when expanding; // re-render the data when expanding to ensure that the data is the latest if (! This. tree. rendered) {// determine whether to render this. tree. render (this. treeid); // rendering}); // if (me. fireEvent ("select", me, record) cannot listen to the select event 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"> 





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.