在extjs4中单击行下载文件

在extjs4中单击行下载文件,extjs4,gridpanel,extjs4.2,Extjs4,Gridpanel,Extjs4.2,我有一个网格面板,其中有一列,如果你向下单击,就会有一个文件关联到这一行。 在extjs 2中,我只定义了一个新的呈现器,它是一个只返回url字符串格式的函数,如下所示: function DownaloadFile(value, metadata, record, rowIndex, colIndex, store) if (record.data.id){ return String.format('<b><a href="<c:url value='/f

我有一个网格面板,其中有一列,如果你向下单击,就会有一个文件关联到这一行。 在extjs 2中,我只定义了一个新的呈现器,它是一个只返回url字符串格式的函数,如下所示:

function DownaloadFile(value, metadata, record, rowIndex, colIndex, store)
if (record.data.id){

     return String.format('<b><a href="<c:url value='/fileDownload.action?id={0}'/>" title="<fmt:message key='button.table.file.download.tooltip'/>"><img src="<c:url value="/icons/icon_download.gif"/>"/></a></b>',record.data.id);
}
函数downaloaddfile(值、元数据、记录、行索引、colIndex、存储)
if(record.data.id){
返回String.format(“”,record.data.id);
}
这种语法在ExtJS4.2中并不严格,因为String.format现在是Ext.String.format,但当我进行此更改时,没有发生任何情况

我尝试以以下方式在列定义中使用新的actioncolumn:

{
                        xtype:'actioncolumn',
                        text: "download", 
                        width:80,
                        items: [{
                                sortable: false, 
                                align:'center',
                                iconCls: 'download_icon',
                                hrefTarget: '_blank',
                                handler: function(grid, rowIndex, colIndex) {
                                    var rec = reportPanel.getStore().getAt(rowIndex);
                                    return Ext.String.format('<b><a href="<c:url value='/fileDownload.action?id={0}'/>" title="download.tooltip"></a></b>',rec.id);
                                }
                        }]
                }
{
xtype:'actioncolumn',
文字:“下载”,
宽度:80,
项目:[{
可排序:false,
对齐:'居中',
iconCls:“下载图标”,
hrefTarget:“\u blank”,
处理程序:函数(网格、行索引、colIndex){
var rec=reportPanel.getStore().getAt(行索引);
返回Ext.String.format(“”,rec.id);
}
}]
}
但有点不对劲,因为javascript调试器没有发生任何类型的错误。
提前感谢。

actioncolumn的
处理程序
属性(它在网格单元格中呈现一个图标或一系列图标,并为每个图标提供一个作用域单击处理程序)记录如下:

单击图标时调用的函数

考虑改用(witch通过使用配置的XTemplate处理模型数据来呈现值)并将
tpl
属性传递给它