动态依赖于数据jsonStore的changeItemTpl

时间:2018-07-28 23:49:25

标签: extjs extjs6 extjs6-classic

我是Sencha ExtJS经典游戏的初学者!

我需要将内容更改为dataview itemTpl。

这是我来自jsonstore的数据:

{
    success: true,
    items: {
        idTipoActividad: 1,
        Ejercicios: [{
            idimgCorrect: 1,
            nameAudio: 'brother-in-law',
            images: [{
                id: 1,
                filename: 'https://www.abc.es/Media/201308/01/1--644x362.jpg'
            }, {
                id: 2,
                filename: 'https://www.abc.es/Media/201308/01/1--644x362.jpg'
            }, {
                id: 3,
                filename: 'https://www.abc.es/Media/201308/01/1--644x362.jpg'
            }, {
                id: 4,
                filename: 'https://www.abc.es/Media/201308/01/1--644x362.jpg'
            }]
        }, {
            idimgCorrect: 2,
            nameAudio: 'Home',
            images: [{
                id: 1,
                filename: 'https://upload.wikimedia.org/wikipedia/commons/0/0d/SEAT_600_SIAM_2008.JPG'
            }, {
                id: 2,
                filename: 'https://upload.wikimedia.org/wikipedia/commons/0/0d/SEAT_600_SIAM_2008.JPG'
            }, {
                id: 3,
                filename: 'https://upload.wikimedia.org/wikipedia/commons/0/0d/SEAT_600_SIAM_2008.JPG'
            }, {
                id: 4,
                filename: 'https://upload.wikimedia.org/wikipedia/commons/0/0d/SEAT_600_SIAM_2008.JPG'
            }]
        }]
    }
}

Ejercicios数组应通过单击按钮更改并显示在itemTpl中 这是我的fiddle

1 个答案:

答案 0 :(得分:1)

使用tpl代替itemTpl,并将以下功能附加到dataview

setTemplate: function (template, itemSelector) {
    this.tpl = template;
    this.itemSelector = itemSelector;
    this.refresh();
}

并在您的onBtnNextClick1函数中使用它,如下所示:

refs.viewImages.setTemplate(tpl, 'div.container');

Working fiddle

注意:请检查fiddle中的AudioImagen3.jsMyWindow3ViewController4.js了解详细信息。 (我也更正了一些代码。)

希望这会帮助/指导您。