This was annoying. The Sencha Touch documentation is really bad. I wanted to display data through XML instead of their preferred JSON option. Sure, it is possible but what the samples and even those in the forums failed to show is the one thing that will make it work.

The solution is the keyword mapping in a model class.

The field names are different than the tag names in the XML where case sensitivity is the factor. If your XML looks like this …

And in your model class your field name is specified as

Then when you load the XML data into the store’s reader, the field values will always return null.

In order for this to work, you will have to include the mapping attribute in the model class and declare the XML tag there (see code below).

I hope this post helped you!

There are many possible culprits that gets this error.

1) In my case, the problem lay in my model file where the field names specified did not have a comma after each one of them.

Instead of

my file contained this

The comma at the end of each line was missing. It took me a half day to realize these were missing so make sure you double check your model class files for this.

2) Another may be how you use the model class inside a store. It should be the model class name with the package name included.

3) If you define model classes in the app, make sure that you declare them in the app.js file.

So far, these three are the mistakes that I encountered when I was starting with Sencha. There may be others but the main cause of all these is missing characters ;).

Related Posts Plugin for WordPress, Blogger...