Expert wanna be
Expert wanna be

Reputation: 10624

Need help for Extjs Dataview

I'm tring to use ExtJS dataview (TPL)

but it does not working well. and I can not find any wrong..

anybody know what I do mistake?

Code :

var testPanel = new Ext.Panel({
    border: true,
    height: 400,
    layout : 'fit',
    items : [
        {html : "Print me"}, // ! It print OK
        new Ext.DataView({ // It does not show up!
        store: this.store,
        itemSelector: 'div.showme',
        autoHeight: true,
        tpl : new Ext.XTemplate(
        '<div>HELLO</div>',
        '<tpl for=".">',
            '<div class="showme">',
            '<div>{myData}</div>',
            '</div>',
        '</tpl>'
        ),
        emptyText : 'No Data' // even not print this!
    })],
    store : new Ext.data.JsonStore({
        url : '<?php echo url_for('test.php'); ?>', // It bring data ok.
        fields : [
            {name : 'myData'}
        ]
    }),
    redraw : function(para){
        this.store.load({
        params : {
            para : para
        }
        })
    }
});

Thank you!

Upvotes: 0

Views: 2573

Answers (1)

nscrob
nscrob

Reputation: 4493

there is no need to put the store on the panel, you should put the store directly on the dataview. In this line store: this.store, when you are creating the object this.store will be undefined.

new Ext.DataView({ // It does not show up!
    store: new Ext.data.JsonStore({
        url: '<?php echo url_for('
        test.php '); ?>', // It bring data ok.
        fields: [{
            name: 'myData'
        }]
    }),
    itemSelector: 'div.showme',
    autoHeight: true,
    tpl: new Ext.XTemplate(
        '<div>HELLO</div>',
        '<tpl for=".">',
        '<div class="showme">',
        '<div>{myData}</div>',
        '</div>',
        '</tpl>'),
    emptyText: 'No Data' // even not print this!
});

Upvotes: 3

Related Questions