Reputation: 43
I'm working with Jqgrid and (with you help) I made this formatter:
function editarFormatter(cellvalue, options, rowObject) {
var cellValue = cellvalue;
var url="<a href='editar_equipo.php?equi_id=" + cellValue + "'><img src='images/edit_icon.gif' alt='" + cellValue + "' title='Editar: " + cellValue + "' />Editar</a>";
url+="<a href='eliminar.php?equi_id=" + cellValue + "'><img src='images/trash.png' alt='" + cellValue + "' title='Eliminar: " + cellValue + "' />Eliminar</a>";
return url;
};
What return this as a column for each row:
The "Editar" (Edit) Button redirects without problem to another .php page with a form that edits the info of that row.
But for the Delete button, I don't wanna redirect to another page. Instead, I want a dialog where ask me if I want to delete that row, with "Yes" and "No" options, just like the delete button from the "Actions" Formatter.
I already saw How can I implement a custom jqGrid delete button? and Custom delete button in jqGrid, But can't figure out how apply them to the link whit icon of my formatter.
Any help will be apreciated! :) Thank you in advance!
Upvotes: 1
Views: 2276
Reputation: 221997
You can for example use href
in the <a>
of your custom formatter and use onCellSelect
callback to execute any action on the user click on the button. See the answer for more details.
Alternatively you can use onclick
attribute of the <a>
to start any JavaScript which will be executed if the user click on the link. You can look at the code of dynamicLink formatter (see the answer) to see how you can implement this.
Upvotes: 2