2011-03-01 71 views
0

我試圖渲染功能是這樣的:圖像不顯示的ExtJS渲染功能

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

    } 

的問題是,PDF圖標不顯示。如果我在文字中放置了img,它會顯示正常。我在這裏做錯了什麼(它不適用於任何瀏覽器) 我單獨打開圖標,它可以在所有瀏覽器中打開。

+0

什麼是String.format調用的返回值? – Tommi 2011-03-01 17:05:06

+0

這是:與{0}和{1}取代。爲什麼request.getContextPath()不被評估?謝謝!! – Victor 2011-03-01 17:16:42

回答

0

如果沒有顯示鏈接有問題。

嘗試把只是鏈接,而不是圖像:

pdfRenderer: function(value, metaData, record, rowIndex, colIndex, store){ 
    return String.format('<%=request.getContextPath()%>/static/images/pdf_icon.gif',arg1,arg2); 
    } 

結果會告訴你什麼問題鏈接

0

顯然,有一些問題解決的scriptlet表達式'<%= request.getContextPath( )%'從一個JavaScript函數。
現在,我解決了它使用: 在jsp加載時隱藏的變量Declard input type ='hidden'id ='hidVar'value ='<%= request.getContextPath()%>/static/images/pdf_icon.gif」

在渲染器功能: pdfRenderer:函數(值,元數據,記錄和rowIndex,colIndex和商店){ VAR URL =的document.getElementById( 'hidVar')值。 return String.format(url,arg1,arg2); }