1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    27
    Vote Rating
    0
    sveatlo is on a distinguished road

      0  

    Default Answered: record.get('string') returns undefined

    Answered: record.get('string') returns undefined


    Hi,
    I've got a following treestore:
    Code:
    Ext.define('Statistics.store.Menu', {
        extend: 'Ext.data.TreeStore',
        model: 'Menu',
        storeId: 'MenuStore',
        autoLoad: true,
        autoSync: true,
        
        proxy   : {
            type : 'ajax',
            url  : 'resources/scripts/get_menu.php?callback=1',
            reader: {
                type: 'json',
                successProperty: 'success'
            }
        }
        
        
    });
    The get_menu.php script returns following JSON-formatted reply:

    Code:
    {"success": true,"children": [{"text": "Home","leaf": true},{
                    "text"     : "Moje Firma s.r.o.",
                    "dbName"   : "demo",
                    "leaf"       : false,
                    "expanded" : false,
                    "children" : [
                        {
                            "text" : "Vydane",
                            "leaf" : true
                        },
                        {
                            "text" : "Prijate",
                            "leaf" : true
                        }
                    ]
                },{
                    "text"     : "Já Živnostník",
                    "dbName"   : "demo_de",
                    "leaf"       : false,
                    "expanded" : false,
                    "children" : [
                        {
                            "text" : "Vydane",
                            "leaf" : true
                        },
                        {
                            "text" : "Prijate",
                            "leaf" : true
                        }
                    ]
                },{
                    "text"     : "Nezisková organizace",
                    "dbName"   : "demo_neziskova",
                    "leaf"       : false,
                    "expanded" : false,
                    "children" : [
                        {
                            "text" : "Vydane",
                            "leaf" : true
                        },
                        {
                            "text" : "Prijate",
                            "leaf" : true
                        }
                    ]
                },{
                    "text"     : "Příspěvková organizace",
                    "dbName"   : "demo_prispevkovka",
                    "leaf"       : false,
                    "expanded" : false,
                    "children" : [
                        {
                            "text" : "Vydane",
                            "leaf" : true
                        },
                        {
                            "text" : "Prijate",
                            "leaf" : true
                        }
                    ]
                },{
                    "text"     : "Moje Firma SK s.r.o.",
                    "dbName"   : "demo_sk",
                    "leaf"       : false,
                    "expanded" : false,
                    "children" : [
                        {
                            "text" : "Vydane",
                            "leaf" : true
                        },
                        {
                            "text" : "Prijate",
                            "leaf" : true
                        }
                    ]
                }]}
    When I try to get the text field, everything works fine, but when I try to get the dbName field, it returns undefined.
    Code:
    record.get('text')            //returns the real value
    record.get('dbName')         //returns undefined
    Can somebody help me, please?

    Thanks for any answer

  2. Code:
    Ext.define('Statistics.store.Menu', {
        extend: 'Ext.data.TreeStore',
        model: 'Menu',
    Code:
    Ext.define('Statistics.model.Menu', {
    Your model names don't match.

  3. #2
    Sencha User Fire-Dragon-DoL's Avatar
    Join Date
    Dec 2011
    Posts
    141
    Vote Rating
    1
    Answers
    9
    Fire-Dragon-DoL is on a distinguished road

      0  

    Default


    Quote Originally Posted by sveatlo View Post
    Hi,
    I've got a following treestore:
    Code:
    Ext.define('Statistics.store.Menu', {
        extend: 'Ext.data.TreeStore',
        model: 'Menu',
        storeId: 'MenuStore',
        autoLoad: true,
        autoSync: true,
        
        proxy   : {
            type : 'ajax',
            url  : 'resources/scripts/get_menu.php?callback=1',
            reader: {
                type: 'json',
                successProperty: 'success'
            }
        }
        
        
    });
    The get_menu.php script returns following JSON-formatted reply:

    Code:
    {"success": true,"children": [{"text": "Home","leaf": true},{
                    "text"     : "Moje Firma s.r.o.",
                    "dbName"   : "demo",
                    "leaf"       : false,
                    "expanded" : false,
                    "children" : [
                        {
                            "text" : "Vydane",
                            "leaf" : true
                        },
                        {
                            "text" : "Prijate",
                            "leaf" : true
                        }
                    ]
                },{
                    "text"     : "Já Živnostník",
                    "dbName"   : "demo_de",
                    "leaf"       : false,
                    "expanded" : false,
                    "children" : [
                        {
                            "text" : "Vydane",
                            "leaf" : true
                        },
                        {
                            "text" : "Prijate",
                            "leaf" : true
                        }
                    ]
                },{
                    "text"     : "Nezisková organizace",
                    "dbName"   : "demo_neziskova",
                    "leaf"       : false,
                    "expanded" : false,
                    "children" : [
                        {
                            "text" : "Vydane",
                            "leaf" : true
                        },
                        {
                            "text" : "Prijate",
                            "leaf" : true
                        }
                    ]
                },{
                    "text"     : "Příspěvková organizace",
                    "dbName"   : "demo_prispevkovka",
                    "leaf"       : false,
                    "expanded" : false,
                    "children" : [
                        {
                            "text" : "Vydane",
                            "leaf" : true
                        },
                        {
                            "text" : "Prijate",
                            "leaf" : true
                        }
                    ]
                },{
                    "text"     : "Moje Firma SK s.r.o.",
                    "dbName"   : "demo_sk",
                    "leaf"       : false,
                    "expanded" : false,
                    "children" : [
                        {
                            "text" : "Vydane",
                            "leaf" : true
                        },
                        {
                            "text" : "Prijate",
                            "leaf" : true
                        }
                    ]
                }]}
    When I try to get the text field, everything works fine, but when I try to get the dbName field, it returns undefined.
    Code:
    record.get('text')            //returns the real value
    record.get('dbName')         //returns undefined
    Can somebody help me, please?

    Thanks for any answer
    Model definition? We need it to check if you didn't forget to update fields there.

  4. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    27
    Vote Rating
    0
    sveatlo is on a distinguished road

      0  

    Default


    Model:
    Code:
    Ext.define('Statistics.model.Menu', {
        extend: 'Ext.data.Model',
        
        fields: [
            {name: 'text', type: 'string'},
            {name: 'dbName', type: 'string'},
            {name: 'leaf', type: 'boolean'},
            {name: 'expanded', type: 'boolean', defaultValue: false} 
        ],
    
    
    });

  5. #4
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,626
    Vote Rating
    332
    Answers
    551
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Code:
    Ext.define('Statistics.store.Menu', {
        extend: 'Ext.data.TreeStore',
        model: 'Menu',
    Code:
    Ext.define('Statistics.model.Menu', {
    Your model names don't match.

Thread Participants: 2