代码之家  ›  专栏  ›  技术社区  ›  Alex L

extjs:如何用树节点的直接子节点填充组合框?

  •  1
  • Alex L  · 技术社区  · 16 年前

    1. 我需要获取节点1的直接子节点,并将它们放置在组合框中。

    2. 从组合框列表中选择节点时,树应仅显示该节点及其子节点。

    任何帮助都将不胜感激。

    1 回复  |  直到 16 年前
        1
  •  1
  •   Steven de Salas Alexander Bollaert    15 年前

    在ExtJS API文档中查找过滤功能。在左上角的“查找类”中,您可以通过输入字符串过滤树。我认为您要做的与此非常相似:

    http://dev.sencha.com/deploy/dev/docs/

    向下滚动至 功能:
    http://dev.sencha.com/deploy/dev/docs/resources/docs.js

    filterTree: function(t, e){
        var text = t.getValue();
        Ext.each(this.hiddenPkgs, function(n){
            n.ui.show();
        });
        if(!text){
            this.filter.clear();
            return;
        }
        this.expandAll();
    
        var re = new RegExp('^' + Ext.escapeRe(text), 'i');
        this.filter.filterBy(function(n){
            return !n.attributes.isClass || re.test(n.text);
        });
    
        // hide empty packages that weren't filtered
        this.hiddenPkgs = [];
            var me = this;
        this.root.cascade(function(n){
            if(!n.attributes.isClass && n.ui.ctNode.offsetHeight < 3){
                n.ui.hide();
                me.hiddenPkgs.push(n);
            }
        });
    },