带有名称的型号不存在问题sencha touch 2



我最近刚刚开始使用Sencha Touch 2。我在读取XML数据时遇到问题。错误:

 Uncaught Error: [ERROR][Ext.data.Store#setModel] Model with name "MyApp2.model.TabBarModel" does not exist. 

我错过了什么?

型号:

    Ext.define("MyApp2.model.TapBarModel", {
   extend: "Ext.data.Model",
  config: {
type:'tree',
fields: [
{name: 'id', type: 'auto',mapping:'module.id'}
   ]
} 
      });

商店:

  Ext.define("MyApp2.store.TabBarStore", {
extend: "Ext.data.Store",
requires: ["Ext.data.proxy.JsonP","Ext.data.reader.Xml"],
config: {
    model: "MyApp2.model.TabBarModel",
    autoLoad: true,
    id: 'TabBarStr',
    proxy: {
        type: 'jsonp',
        url: 'http://mysite.com/api/applications/894/config?format=jsonp&appviewer=1&lang=fr&access_token=' + token,
        reader: {
            type: 'xml',
            root: 'application',
            record:'module'
        }
    }
}
  });

我的文件:

 {"status":"ok","config":"<?xml version="1.0"?>n
 <application id="4" name="name" > 
 <modules>
 <module id="32" >
 </module>
  .....
  </modules>
    </application>n"}

您读取的是JSON文件,而不是XML。其中一个JSON对象恰好是一些字符串化的XML,但这并不能改变您正在读取JSON的事实。

您可以将代理更改为读取json,并正确处理结果。或者(我强烈建议)将远程Web服务更改为返回JSON或XML,而不是JSON或其他格式的XML。

试试这样的东西:

Ext.data.JsonP.request({
    url: yourUrl,
    params: {
        ...
    },
    success: function(result) {
        var xml = result.config;
        //Parse xml here
        Ext.getStore('TabBarStore').add(yourNewXmlStuffInAnArray);
    }
}

最新更新