image does not show in extjs render function
I am trying a renderer function like this:
pdfRenderer: function(value, metaData, record, rowIndex, colIndex, store){
return String.format('<a href="#" onclick="openPdf({0},{1})"><img src="<%=request.getContextPath()%>/static/images/pdf_icon.gif"/></a>',arg1,arg2);
}
The problem is that the pdf icon does not show. If I put in a t开发者_如何学Pythonext in place of the img, it shows fine. What am I doing wrong here.(It works in none of the browsers) I opened the icon separately and it can open in all browsers.
If does not show up there is problem with link.
Try to place just link instead image:
pdfRenderer: function(value, metaData, record, rowIndex, colIndex, store){
return String.format('<%=request.getContextPath()%>/static/images/pdf_icon.gif',arg1,arg2);
}
result will show you what problem with link is
Apparently, there is some problem with resolving scriptlet expressions '<%=request.getContextPath()%' from inside a javascript function.
For now, I solved it using :
Declar a hidden variable in jsp when it loads
input type = 'hidden' id = 'hidVar' value = ' <%=request.getContextPath()%>/static/images/pdf_icon.gif'
In the renderer function: pdfRenderer: function(value, metaData, record, rowIndex, colIndex, store){ var url = document.getElementById('hidVar').value; return String.format(url,arg1,arg2); }
精彩评论