2017-01-27 33 views
0

我使用的dojo EngngGrid有5列,第五列是圖像超鏈接。我想用文本特定行替換超鏈接。例如,我點擊第五列的第二行。當我點擊圖像和我的圖像超鏈接替換一些文字。任何人都可以幫助解決這個問題嗎?如何用dojo中的文字替換超鏈接EnhanceGrid?

For example 
<th field="mobileNumber" noresize="true" formatter="formatMobileNumber" width="10" cellClasses="alignTextCenter">Mobile Number</th> 

<span style="display:none" id="defaultFormatMobileNumber_${ns}"> 
<a href="javascript:void(0);" onClick="showMobileNumber(event,valueToChange)"> 
<img src='/images/mobile.png' /> 
</a> 
</span> 

function formatMobileNumber(data, rowId){ 
var link = dojo.byId('defaultFormatMobileNumber').innerHTML; 
link = link.replace("valueToChange",rowId); 
return link 
} 

function showMobileNumber_<p:namespace/>(e,rowIdx){ 
//here I want to replace my link with some text 
} 
+0

請張貼您的代碼 – vijay

回答

0

您要顯示的文本應由格式化程序返回。你可以有showMobileNumber設置一些變量,說clickedRow,被點擊的行數和適應formatMobileNumber採取這一變量考慮在內:

clickedRow = -1; 

function formatMobileNumber(data, rowId){ 
    if (clickedRow != rowId) { 
    var link = dojo.byId('defaultFormatMobileNumber').innerHTML; 
    link = link.replace("valueToChange",rowId); 
    return link; 
    } 
    else { 
    return "some text"; 
    } 
} 

function showMobileNumber_<p:namespace/>(e,rowIdx){ 
    clickedRow = rowIdx; 
    // now the grid should probably be refreshed so that the formatter is 
    // re-applied. If variable 'grid' holds the grid: 
    // grid._refresh(); 
} 
相關問題