Results 1 to 2 of 2

Thread: loading dataIndex tree.Panel

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    27
    Vote Rating
    -1
      0  

    Default loading dataIndex tree.Panel

    Hi, I'm doing a really simple tree.Panel, and Im trying to use some columns but it doesnt load the dataindex apart from the 'text' one... this is the code:

    Code:
    var store = Ext.create('Ext.data.TreeStore', {            
                root : {
                    expanded : true,
                    children : [{
                                text : "detention",
                                description : 'asdfasdf',
                                leaf : true
                            }, {
                                text : "homework",
                                description : "asdfasdf",
                                children : [{
                                            text : "book report",
                                            description : 'hola',
                                            leaf : true
                                        }, {
                                            text : "alegebra",
                                            description : "haha",
                                            leaf : true
                                        }]
                                
                            }, {
                                text : "buy lottery tickets",
                                description : "kajsdf",
                                leaf : true
                            }]
                }
            });
    
    
    Ext.define('managerUserText', {
                extend : 'Ext.tree.Panel',
    
    
                initComponent : function() {
                    var me = this;
                    me.store = store;
                    me.fields = ['text', 'des'];
                    me.columns = [{
                                xtype : 'treecolumn',
                                text : 'i_Property',
                                dataIndex : 'text',
                                width : 200
                            }, {
                                text : 'i_Description',
                                dataIndex : 'description',
                                flex : 1,
                                width : 200
                            }];
                    me.callParent(arguments);
                }
            })
    Thank you for any help...

  2. #2
    Sencha User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,062
    Vote Rating
    1391
      0  

    Default

    You shouldn't use Ext.create outside of Ext.define or Ext.onReady. If you have more than one instance of this tree panel, it will share the same store.

    The issue is your store didn't know about the description field:

    Code:
    Ext.define('managerUserText', {
        extend : 'Ext.tree.Panel',
    //TODO NEED AN ALIAS
    
        initComponent : function() {
            var me = this;
    
            me.store = Ext.create('Ext.data.TreeStore', {
                fields : ['text', 'description'],
                root : {
                    expanded : true,
                    children : [{
                        text : "detention",
                        description : 'asdfasdf',
                        leaf : true
                    }, {
                        text : "homework",
                        description : "asdfasdf",
                        children : [{
                            text : "book report",
                            description : 'hola',
                            leaf : true
                        }, {
                            text : "alegebra",
                            description : "haha",
                            leaf : true
                        }]
                    }, {
                        text : "buy lottery tickets",
                        description : "kajsdf",
                        leaf : true
                    }]
                }
            });
    
            me.columns = [{
                xtype : 'treecolumn',
                text : 'i_Property',
                dataIndex : 'text',
                width : 200
            }, {
                text : 'i_Description',
                dataIndex : 'description',
                flex : 1,
                width : 200
            }];
    
            me.callParent(arguments);
        }
    });
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

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