Extjs 动态输出(使用XTemplate)(二)

this.getAttachementStore().load({
            callback: function (records, operation, success) {
                var json = Ext.decode(operation.response.responseText);
                var data = {
                    files: json.data
                };

                var strTable = "";
                strTable += '<table width="32%" border="0">';
                strTable += '<tr>';
                strTable += '<td>&nbsp;</td>';
                strTable += '</tr>';
                strTable += '</table>';

                strTable += '<table width=\"32%\" border=\"0\"  cellspacing=\"10\" cellpadding=\"5\">';
                strTable += '<tr>';
                strTable += '<td style=\"line-height:10px\"></td>';
                strTable += '</tr>';
                strTable += '<tr>';
                strTable += '<td width=\"19%\" rowspan=\"4\">&nbsp;</td>';
                strTable += '<td width=\"81%\">&nbsp;<span style="font-size:12px; "><b>{fileName}</b></span></td>';
                strTable += '</tr>';
                strTable += '<tr>';
                strTable += '<td style=\"line-height:10px\"></td>';
                strTable += '</tr>';
                strTable += '<tr>';
                strTable += '<td>';
                strTable += '<a href="#" style="font-size:12px;color:#CCCCCC;"><b>下载</b></a>&nbsp;&nbsp;';
                strTable += '<a href="#" style="font-size:12px;color:#CCCCCC;"><b>删除</b></a>';
                strTable += '<td>';
                strTable += '</tr>';
                strTable += '</table>';

                var tpl = new Ext.XTemplate(
                '<tpl for="files">',
                    strTable,
                    '</tpl>'
                );

                //tpl.overwrite(Ext.getCmp('uploadFileInfos').body, data);
                Ext.getCmp('uploadFileInfos').data = data;
                Ext.getCmp('uploadFileInfos').tpl = tpl;
            },
            scope: this
        });

var thePanel ={
                xtype: 'panel',
                id: 'uploadFileInfos',
                title: '附件信息(2个)',
                hideHeaders: true,
                collapsible: true,
                scroll: 'both',
                autoScroll: true,
                labelWidth: 100,
                height: 200,
                padding: '10px 0px 0px 0px'
            };

 

posted @ 2013-01-25 15:58  xust  阅读(223)  评论(0)    收藏  举报