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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,416
    Vote Rating
    1270
      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
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

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

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
  •