Render customize component inside XTemplate

白昼怎懂夜的黑 提交于 2019-12-13 12:23:01

问题


Ext.define('GB.view.DigestList',{
    extend: 'Ext.panel.Panel',
    alias:'widget.digestlist',

            items:[ {
                xtype:'dataview',
                store: 'GB.store.Digests',
                tpl: new Ext.XTemplate(
                          '<tpl for=".">',
                            '<div class="container">',
                              '{name}',
                              '<div class="davidfun"></div>',
                            '</div>',
                          '</tpl>'
                ),      
                listeners: {
                    viewready: function(){
                        var home_d = Ext.create('GB.view.MyOwnDigest');
                        home_d.render(Ext.query('.davidfun')[0]);
                        // home_d.render(Ext.getBody()); <- it'll work fine with this line
                    },
                }
              }],

    bind: function(record, store) {
        this.getComponent(0).bindStore(record);
    }

});


Ext.define('GB.store.Digests', {
    extend:'Ext.data.Store',
    model: 'GB.model.Digest',
    data:[
        {'name':'name111'},
        {'name':'name222'}
    ]
});

Does someone know why can't i get div class which is "davidfun" that in Xtemplate by Ext.query('.davidfun')[0],

it'll always show 'undefined', thanks for your response first:)

Code UPDATE:

Problem resolved!


回答1:


You can try the "viewready" event of the dataview.

See my example http://jsfiddle.net/2huvt/



来源:https://stackoverflow.com/questions/12597830/render-customize-component-inside-xtemplate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!