1. #1
    Sencha User
    Join Date
    May 2012
    Posts
    2
    Vote Rating
    0
    phanikumar is on a distinguished road

      0  

    Default Unanswered: Store Not Loaded in MVC based app

    Unanswered: Store Not Loaded in MVC based app


    Hi,

    I am new to SenchaTouch Dev, creating an MVC app with Sencha Docs help. But I am stuck at loading a store. In my example model is not accessed from the store.

    In the browser it sending request and getting xml response.

    I read and went through some articles for store and proxies but they are implemented different.

    Here am positing my code, please help me solve this issue. Also guide me for the best MVC implementation.

    Code:
        Contronller:-     var store1 = Ext.create('x.store.edAuthenticateStore',{});
            store1.setProxy({
                type:'ajax',
                url:'AppURL',
                reader:{
                    type:'xml',
                    rootProperty:"mbsResponse"
                },
                autoLoad:true
            });
            store1.load();
    
            alert(store1.getModel().get('membername'));
    
    
    Store:-
    Ext.define('x.store.edAuthenticateStore',{
        extend:'Ext.data.Store',
        requires:['Ext.data.reader.Xml'],
        config:{
            storeId:'authStore',
            model:'edTouch.model.edAuthenticateUserResult'
        }
    });
    
    
    Models:- 
    1) edAuthenticateUserResult'
        Ext.define('edTouch.model.edAuthenticateUserResult',{
        extend:'Ext.data.Model',
        config:{
            id:'edAuthResult',
            fields:[
               {name:'memberid', type:'string'},
               {name:'membername', type:'string'},
               {name:'mbsstatuscode', type:'string'}, 
               {name:'mbsstatustext', type:'string'}
            ],
            hasMany:{
                model:'edTouch.model.edChild',
                name:'children'
            },
            hasOne:{
                model:'edTouch.model.edSchoolDetails',
                name:'schoolDetails'
            }        
    
    
        }
    });
    2) edChild
        Ext.define('x.model.edChild',{
        extend:'Ext.data.Model',
        config:{
            fileds :[
              {name:'studentid', type:'string'},
              {name:'firstname', type:'string'},
              {name:'lastname' ,type:'string'},
              {name:'rollnumber', type:'string'},
              {name:'classid', type:'string'},
              {name:'classname', type:'string'},
              {name:'sectionid', type:'string'},
              {name:'sectionname', type:'string'},
              {name:'imagepath', type:'string'},                
            ]
        }
    });
    3)
        Ext.define('x.model.edSchoolDetails',{
        extend:'Ext.data.Model',
        config:{
            fields:[           
              {name:'schoolid', type:'string'},
              {name:'schoolname', type:'string'},
              {name:'schoolImage' ,type:'string'},
              {name:'schoolweburl', type:'string'},
              {name:'location', type:'string'}
            ]
        }
    });
    
    
    _______ xml ________
    
    
    <authenticateUserResponse xmlns="http://tempuri.org/">
    <authenticateUserResult>
    <mbsResponse xmlns="">
    <mbsstatuscode>200</mbsstatuscode>
    <mbsstatustext>Success</mbsstatustext>
    <memberid>101</memberid>
    <membername>xyz</membername>
    <schoolDetails>
    <schoolid>5</schoolid>
    <schoolname>abacd</schoolname>
    <schoolImage>123.jpg</schoolImage>
    <schoolweburl>www.google.com</schoolweburl>
    <location>IND</location>
    </schoolDetails>
    <children>
    <child>
    <studentid>1</studentid>
    <firstname>FName</firstname>
    <lastname>M</lastname>
    <rollnumber>123001</rollnumber>
    <classid>1</classid>
    <classname>1ST CLASS</classname>
    <sectionid>1</sectionid>
    <sectionname>A</sectionname>
    <imagepath>201312210145183111226-151723.jpg</imagepath>
    </child>
    </children>
    </mbsResponse>
    </authenticateUserResult>
    </authenticateUserResponse>

    Thanks,
    Phani

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,629
    Answers
    3452
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    To get a record from a store you need to wait for the store to load either via a callback or an event listener, if you do a store.load and then right after it expect the store to be loaded then you will always get undefined.

    To get a record you can use store.getAt(0) or one of the many find methods on the store. The way you are doing it will not work.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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.

Thread Participants: 1

Tags for this Thread