Results 1 to 10 of 10

Thread: extend ComboBox

  1. #1
    Ext User
    Join Date
    Dec 2008
    Posts
    4
    Vote Rating
    0
      0  

    Question extend ComboBox

    //code TreeComboBox.js

    Code:
     
     
    Ext.ux.TreeComboBox = Ext.extend(Ext.form.ComboBox, {
        extStore: null,
        tree: null,
        treeId: 0,
        setValue: function(v) {
            var text = v;
            if (this.valueField) {
                var r = this.findExtRecord(this.valueField, v);
                if (r) {
                    text = r.data[this.displayField];
                } else if (this.valueNotFoundText !== undefined) {
                    text = this.valueNotFoundText;
                }
            }
            Ext.ux.TreeComboBox.superclass.setValue.call(this, text);
            this.lastSelectionText = text;
            if (this.hiddenField) {
                this.hiddenField.value = v;
            }
            this.value = v;
        },
        initComponent: function() {
            this.treeId = Ext.id();
            this.focusLinkId = Ext.id();
            Ext.apply(this, {
                store: new Ext.data.SimpleStore({
                    fields: [],
                    data: [[]]
                }),
                editable: false,
                shadow: false,
                mode: 'local',
                triggerAction: 'all',
                maxHeight: 200,
                tpl: '<tpl for="."><div style="height:200px"><div id="'
                + this.treeId + '"></div></div></tpl>',
                selectedClass: '',
                onSelect: Ext.emptyFn,
                valueField: 'id'
            });
            var treeConfig = {
                border: false,
                rootVisible: false
            };
            Ext.apply(treeConfig, this.treeConfig);
            if (!treeConfig.root) {
                treeConfig.root = new Ext.tree.AsyncTreeNode({
                    text: 'treeRoot',
                    id: '0'
                });
            }
            this.tree = new Ext.tree.TreePanel(treeConfig);
            this.on('expand', this.onExpand);
            this.tree.on('click', this.onClick, this);
            Ext.ux.TreeComboBox.superclass.initComponent.apply(this,
            arguments);
        },
        findExtRecord: function(prop, value) {
            var record;
            if (this.extStore != null) {
                if (extStore.getCount() > 0) {
                    extStore.each(function(r) {
                        if (r.data[prop] == value) {
                            record = r;
                            return false;
                        }
                    });
                }
            }
            return record;
        },
        onClick: function(node) {
            if (node.attributes.parameter == 9) {
                // 
            } else {
                // 
                this.setValue(node.text);
                this.hiddenField.value = node.id;
                this.collapse();
            }
        },
        onExpand: function() {
            this.tree.render(this.treeId);
        }
    });
    Ext.reg("Ext.ux.treecombobox", Ext.ux.TreeComboBox);
    //create TreeComboBox

    {
    xtype: 'Ext.ux.treecombobox',
    extStore :3, //have no effect ?extStore is still null?Why????
    ...............................
    }

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,644
    Vote Rating
    60
      0  

    Default

    Format your post. It is unreadable.

    http://extjs.com/forum/showthread.php?t=43718
    Longtime Sencha geek. Outspoken advocate of pure Javascript Views. Posts my own opinions.

  3. #3
    Ext User
    Join Date
    Dec 2008
    Posts
    4
    Vote Rating
    0
      0  

    Default

    the property extStore is not 3, but null . why?

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,644
    Vote Rating
    60
      0  

    Default

    There is no variable called extStore. You did not declare one.

    Properties of the config, are copied into the Component.
    Longtime Sencha geek. Outspoken advocate of pure Javascript Views. Posts my own opinions.

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,644
    Vote Rating
    60
      0  

    Default

    Code:
            if (this.extStore != null) {
                if (extStore.getCount() > 0) {
    See the difference between those two lines?
    Longtime Sencha geek. Outspoken advocate of pure Javascript Views. Posts my own opinions.

  6. #6
    Ext User
    Join Date
    Dec 2008
    Posts
    4
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by Animal View Post
    Code:
            if (this.extStore != null) {
                if (extStore.getCount() > 0) {
    See the difference between those two lines?
    Code:
            if (this.extStore != null) {//I set break point , the value of this.extStore is null,not 3
                if (extStore.getCount() > 0) {

  7. #7
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,644
    Vote Rating
    60
      0  

    Default

    And what is this when you break there?
    Longtime Sencha geek. Outspoken advocate of pure Javascript Views. Posts my own opinions.

  8. #8
    Ext User
    Join Date
    Dec 2008
    Posts
    4
    Vote Rating
    0
      0  

    Default

    thank you for your help
    Issue is resolved

    after I checked the value of this,I find myself made a mistake.

  9. #9
    Ext Premium Member
    Join Date
    Mar 2010
    Posts
    42
    Vote Rating
    0
      0  

    Default Need info on how to use it

    Hi All,

    I need a treecontrol in a combobox. Need some info on how to use it. How do i pass the store to the tree... Can you share a working example?

  10. #10
    Ext Premium Member
    Join Date
    Mar 2010
    Posts
    42
    Vote Rating
    0
      0  

    Default

    Basically i need the json store representation...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •