XML Reader Does Not Bind Values To Model In Sencha Touch

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 …

<Users>
  <User>
   <Name>tech</Name>
   <Id>1</Id>
  </User>
</Users>

And in your model class your field name is specified as

Ext.define('SS.model.User', {
    extend: 'Ext.data.Model',
    config: {
        fields: [
            { name: 'name', type: 'string' }
        ]
    }
});

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).

fields: [
    { name: 'name', type: 'string', mapping: 'Name' }
]

I hope this post helped you!

Donations appreciated. Every little $ helps. Or click Google +1. Or play the short video on the upper right of this page.

ezPDF Reader For Android, Way Better Than Adobe PDF Reader

I was disappointed when I tried to view my house plan using Adobe PDF Reader in my Android phone because now all details were displayed. There were lines on the side that were hidden. Considering that Adobe made the PDF format quite famous, one would think there would be no problems loading them.

In the iOS, it is ok but in Android it does not. So I had to look for other alternatives. ezPDF Reader while not free actually displayed every detail of the PDF file that I wanted to look into. So now, this is my official PDF reader app for my Android device.

If you think Adobe’s PDF Reader app displays some of your PDF files, you will come to a point where one of your PDF files does not get displayed correctly. There is a reason why some apps are paid and that is because they offer more powerful features than what a free app can give.

I give ezPDF Reader a thumbs up.

Donations appreciated. Every little $ helps. Or click Google +1. Or play the short video on the upper right of this page.

Related Posts Plugin for WordPress, Blogger...