Wednesday 15 September 2010

xml - Model with name does not exist issue sencha touch 2 -


I have recently started working with Sencha Touch 2. I have a problem reading XML data. Error:

  Unwanted error: [Error] The model "MyApp2.model.TabBarModel" does not exist with the name [Ext.data.Store # setModel]   < P> What am I missing?  

Model:

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

Store:

  Ext.define ("MyApp2.store.TabBarStore", {extension: "Ext.data.Store", required: [ "Ext.data.proxy.JsonP", "Ext.data.reader.xml"], Config: {Model: "MyApp2.model.TabBarModel", Autoadload: 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'}}}});   

My file:

  {"status": "ok", "config": "& lt ;? xml version = \" 1.0 \ " ? & Gt; \ n & lt; application id = \ "4 \" name = \ "name \" & gt; module & gt; & lt; module id = \ "32 \" & gt; & lt; ; \ / Module> ..... & lt; / modules & gt; & lt; / application & gt; \ n "}    

< Div class = "post-text" itemprop = "text">

You are reading a JSON-file, not XML. One of the JSON-objects is some Stratified XML, but it does not change the fact that you are reading JSON.

You can either change the proxy to read JSO, and handle the result correctly or (which I strongly recommend) back to JSON or XML in JSON or something else in your Change the remote web service.

Try doing something like this:

  Ext.data .JsonP.request ({url: yourUrl, params: {...}, success: function (result ) {Var xml = result.config; // Add Parsed XML here Ext.getStore ('TabBarStore'). (YourNewXmlStuffInAnArray);}}    

No comments:

Post a Comment