0

I have the following structure for a blog:

<channel>
 <item>
 <title>title of post</title>
(...)
 <gallery folder="path_to_gallery">
  <image>path_to_image</image>
  <image>path_to_other_image</image>
 </gallery>
 <gallery folder="path_to_other_gallery">
  <image>path_to_new_image</image>
  <image>path_to_other_new_image</image>
 </gallery>
</item>
</channel>

Now for this, I have an extjs model with a hasManyAssociation. The upper model works fine, apart from the gallery items. My models look like this:

Parent model:

Ext.define('App.model.News', {
    extend: 'Ext.data.Model',
    config: {
        fields: [{
            name: 'title'
        }, {
            name: 'description'
        }, {
            name: 'thumbnail'
        }, {
            name: 'pubDate',
            type: 'date'
        }],
        hasMany: {
            associationKey: 'gallery',
            primaryKey: 'folder',
            model: 'App.model.Gallery'
        }
    }
});    

child model:

Ext.define('App.model.Gallery', {
    extend: 'Ext.data.Model',
    config: {
        fields: [{
            name: 'image'
        }, {
            mapping: '@folder',
            name: 'folder'
        }]
    }
});

Anyone have a clue what I'm doing wrong?

Darin Kolev
  • 3,401
  • 13
  • 31
  • 46
QuintenVK
  • 749
  • 1
  • 9
  • 20

1 Answers1

0

I ended up not using a model for the galleries and just accessing the raw data. This allowed me to use the nodes, just like DOM elements.

For future reference, here's a code sample:

itemTapped: function(dataview, index, target, record, e, eOpts) {

    var html = '<h2>' + record.get('title') + '</h2>';
    html += record.get('encoded');

    var raw = this.down('#mylist').getStore().data.items[index].raw;
    //further processing happens here. 'raw' contains the complete item-tag as a 
    //DOM object, so we can use querySelectorAll, getAttribute, etc.

}
QuintenVK
  • 749
  • 1
  • 9
  • 20