我正在使用道场EnganceGrid,它有5列,第五列是图像超链接。我想用文本特定的列行替换超链接。例如,我正在单击第五列的第二行。当我单击图像和我的图像超链接时,请替换为一些文本。任何人都可以帮助解决此问题吗?
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
}
要显示的文本应由格式化程序返回。您可以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();
}