i have a grid panel with a column that if you click you downalod a file associate to this row. In extjs 2 i just define a new renderer that is a function who return only return the String format of an url like this:
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);
}
This syntax is not rigth in ExtJS4.2 because String.format is now Ext.String.format but when i made this change nothig happens.
I try to use the new actioncolumn in the column definition in this way:
{
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);
}
}]
}
but something is wrong because javascript debugger doesn't made any type of error. Thanks in advance.
The handler
property of actioncolumn
(witch renders an icon, or a series of icons in a grid cell, and offers a scoped click handler for each icon) is documented as:
A function called when the icon is clicked.
Consider using the templatecolumn
(witch renders a value by processing a Model's data using a configured XTemplate) instead and passing it a tpl
property.