0

我的博客结构如下:

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

现在为此,我有一个带有 hasManyAssociation 的 extjs 模型。上部模型工作正常,除了画廊项目。我的模型如下所示:

父模型:

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'
        }
    }
});    

子模型:

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

有人知道我做错了什么吗?

4

1 回答 1

0

我最终没有为画廊使用模型,而只是访问原始数据。这允许我使用节点,就像 DOM 元素一样。

为了将来参考,这里有一个代码示例:

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.

}
于 2013-05-13T15:54:50.800 回答