1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Vote Rating
    0
    guoal is on a distinguished road

      0  

    Default TreeStore getNodeById fails to get the node

    TreeStore getNodeById fails to get the node


    Hey All,

    I have defined a TreeCombo. The combo is supposed to get a string(which contains some nodes) and then mark those nodes as checked, but I cannot get a node using getNodeById().

    Below is part of the TreeCombo code.

    Plz help.

    Here is the part code of treeComboBox.
    Code:
    Ext.define('xxx.TreeComboBox', {
        extend: 'Ext.form.field.ComboBox',
        url: '',
        tree: {},
        textProperty: 'text',
        valueProperty: '',
        initComponent: function () {
            Ext.apply(this, {
                editable: false,
                queryMode: 'local',
                select: Ext.emptyFn
            });
    
    
            this.displayField = this.displayField || 'text',
            this.treeid = Ext.String.format('tree-combobox-{0}', Ext.id());
            this.tpl = Ext.String.format('<div id="{0}"></div>', this.treeid);
    
    
            if (this.url) {
                var me = this;
                Ext.create('Ext.data.TreeStore', {
                	storeId: 'treeComboStore',
                	autoLoad: true,
                    sorters: [
                        {
                            property: 'leaf',
                            direction: 'ASC'
                        },
                        {
                            property: 'text',
                            direction: 'ASC'
                        }
                    ],
                    folderSort: true,
                    proxy: { 
                    	type: 'ajax', 
                    	url: this.url
                    },
                    fields: [
                             {name: 'text', type: 'string'},
                             {name: 'id', type: 'string'}
                    ]
                });
                this.tree = Ext.create('Ext.tree.Panel', {
                    rootVisible: false,
                    autoScroll: true,
                    height: 200,
                    store: 'treeComboStore'
                });
    
    
    
    
                this.tree.on('itemclick', function (undefined, record) {
                    me.checkChildren(record, !record.get('checked'));                	
                    me.checkParent(record, record.get('checked'));
                	me.setValue(me.getSelectedValue(me.tree.getRootNode()));
                });
    Here is the code to create the treeCombo.
    Code:
    	var treeCombo = Ext.create('xxx.TreeComboBox', {
    		id: 'treecombo',
    		fieldLabel: param,
    	    renderTo: 'treeCombo',
    	    width: 250,
    	    url: '......json'
    	});
    	
    
    
    	treeCombo.setValue(checkedItem);
    	var items = checkedItem.split(',');  
    	var treeStore = Ext.data.StoreManager.lookup('treeComboStore');
    	for(var i=0;i<items.length;i++){
    		var record = treeStore.getNodeById(items[i]);
    		alert("record = "+record.get('text'));
    		treeCombo.fireEvent('itemclick',this,record);
            }

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    34,121
    Vote Rating
    453
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    What Ext JS 4 version are you using?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Vote Rating
    0
    guoal is on a distinguished road

      0  

    Default


    I have solve the pro somehow. If I use storeId for store instead of some variable, the getNodeById works fine in IE, but it still won't work in Chrome.

    Could you help me with this?

  4. #4
    Sencha User
    Join Date
    Oct 2012
    Posts
    6
    Vote Rating
    0
    guoal is on a distinguished road

      0  

    Default


    BTW, I am using Ext4.1