I have a jqGrid which has an action column containing the buttons of "edit" and "delete". The requirement is when the user click the "Delete" button in the action column. The row is not deleted, but marked to be deleted. Thus, my implementation is to remove the "edit" button and replace "delete" button with "undeleted" button. Following are the code
jQuery('#grid').jqGrid({
datatype: 'local',
colNames:[
'action',
... other columns
],
colModel:[
{ name:'action', formatter:actionLink, align:'center', sortable:false, width:150},
... other columns
],
height: 'auto',
width: 935
});
function actionLink(cellvalue, options, rowObject) {
var editImg = '<img width="16" height="16" border="0" alt="Edit" src="${contextPath}/images/edit.png">';
var deleteImg = '<img width="16" height="16" border="0" alt="Delete" src="${contextPath}/images/delete.png">';
var editLink = '<a href="javascript:void(0)" onclick="edit(' + options.rowId + ');">' + editImg + '</a>';
var deleteLink = '<a href="javascript:void(0)" onclick="delete(' + options.rowId + ');">' + deleteImg + '</a>';
return editLink + ' ' + deleteLink;
}
function delete(rowId) {
var selectedObj = jQuery('#rid').jqGrid('getRowData', rowId);
var unDeleteImg = '<img width="16" height="16" border="0" src="${contextPath}/images/arrow_undo.png" />';
selectedObj.action = '<a href="javascript:void(0)" onclick="unDelete(' + rowId + ');">' + unDeleteImg + '</a>';
jQuery('#grid').jqGrid('setRowData', rowId, selectedObj);
}
The action column still display "edit" and "delete" buttons rather than just "undo" button. What did I do wrong? Is it the problem of formatter function actionLink?