2017-01-27 47 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(); 
} 
相关问题