weihao_99999 2009-07-28 11:40
浏览 215
已采纳

下拉树的问题

[size=small][b]http://www.iteye.com/topic/212842

我照着这个做了一个下拉树,选完一个节点之后,在去填别的选项,刚选择的节点就清空了,这个怎么回事啊?

附件是图片 。[/b][/size]
[b]问题补充:[/b]
还是不行啊,我重新弄了一遍还是不行。不知道怎么回事
[b]问题补充:[/b]
我刚刚完全拷贝它的例子做了一次,还是这样。
使用的全是他提供的组件也不行 我的是Ext3.0版本的
[b]问题补充:[/b]
http://hi.baidu.com/tzjobs/blog/item/0faad4f542c899e67609d71d.html

试了。还是不行、 我上午用的是这个人的下拉树,但是传值的时候传的总是node.text

  • 写回答

5条回答 默认 最新

  • zhoujuan520 2009-07-28 14:54
    关注

    这个是我用他的,不知道我有没有改过,我是在3.0环境下可以正常使用

    [code="js"]
    Ext.ux.ComboBoxTree = function() {
    this.treeId = Ext.id() + '-tree';
    this.maxHeight = arguments[0].maxHeight || arguments[0].height || this.maxHeight;
    this.maxWidth = arguments[0].maxWidth || arguments[0].width || this.maxWidth;
    this.tpl = new Ext.Template('

    ');
    this.store = new Ext.data.SimpleStore({
    fields : [],
    data : [[]]
    });
    this.selectedClass = '';
    this.mode = 'local';
    this.triggerAction = 'all';
    this.onSelect = Ext.emptyFn;
    this.editable = false;

    // all:所有结点都可选中
    // exceptRoot:除根结点,其它结点都可选
    // folder:只有目录(非叶子和非根结点)可选
    // leaf:只有叶子结点可选
    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.width = this.maxWidth;
    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;
    },
    
    getValue : function() {
        return typeof this.value != 'undefined' ? this.value : '';
    }
    

    });
    Ext.reg('combotree', Ext.ux.ComboBoxTree);
    [/code]

    我是这样使用的,不知道和你的有什么区别

    [code="js"]
    {
    fieldLabel : '模块',
    xtype : 'combotree',
    name : 'module',
    hiddenName : 'question.module',
    allowBlank : false,
    blankText : '必须选择模块!',
    selectNodeModel : 'leaf',
    emptyText : '请选择...',
    tree : {
    xtype : 'treepanel',
    rootVisible : false,
    loader : new Ext.tree.TreeLoader({
    preloadChildren : true,
    clearOnLoad : false
    }),
    root : new Ext.tree.AsyncTreeNode({
    text : '根结点',
    expanded : true,
    children : Ext.help.treeData
    })
    }
    }
    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧