MVC商店未加载

时间:2013-01-29 11:38:39

标签: model-view-controller extjs proxy sencha-touch store

我是SenchaTouch的新手,试图在docs的帮助下创建一个基于MVC的应用程序。

现在我无法从服务中动态加载商店。

我经历了许多相同的链接/讨论,但这些是以不同的方式实现的。

请帮我解决这个问题,并建议在senchatouch中正确实施MVC。

这是我的代码。

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'));

商店:

    Ext.define('x.store.edAuthenticateStore',{
         extend:'Ext.data.Store',
         requires:['Ext.data.reader.Xml'],
         config:{
             storeId:'authStore',
             model:'edTouch.model.edAuthenticateUserResult'
         }
    });

型号:

    //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 _ _

<?xml version="1.0"?>
<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>

1 个答案:

答案 0 :(得分:0)

尝试替换

store1.load();

store1.load({
    scope   : this,
    callback: function(records, operation, success) {
        // check for success and set the value of button        
    }
});