【问题标题】:Need help for Extjs Dataview需要 Extjs Dataview 的帮助
【发布时间】:2011-12-22 00:16:36
【问题描述】:

我正在尝试使用 ExtJS 数据视图 (TPL)

但效果不好。而且我找不到任何错误..

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

代码:

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

谢谢!

【问题讨论】:

    标签: extjs dataview


    【解决方案1】:

    不需要把store放在panel上,直接把store放在dataview上即可。在这一行store: this.store, 中,当您创建对象时 this.store 将是未定义的。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-12
      • 2013-10-09
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      相关资源
      最近更新 更多