Supreeth Supreeth - 7 months ago 42
ASP.NET (C#) Question

I want to get the edit dialog on click of a link..I have attached the code

Here is the ColModel:

{name: "FirstName", index: "FirstName", width: 100, sortable: true, editable:true, formatter: GetRow}

function GetRow(cellvalue, options, rowObject) {
return "<a href='#' class='GetLink'>" + cellvalue + "</a>";
$('.GetLink').click(function (rowid) {
var row = $('#grid').jqGrid('getGridParam', 'selrow');
$('#grid').jqGrid('editGridRow', row, { recreateForm: true, closeAfterEdit: true, closeOnEscape: true, reloadAfterSubmit: false });


Your current code has some disadvantages. I would recommend you to use formatter: "actions" with the option formatoptions: { editformbutton: true } instead of custom formatter to create edit/delete buttons (see the old documentation, which describes the options of the formatter, for example delbutton: false, which remove Delete button) in every row of the grid. The old answer describes the approach more detailed and provides the demo, which demonstrates the usage of formatter: "actions".

If you would do prefer to use custom formatter, then you could use <span> instead of <a>:

return "<span class='GetLink'>" + cellvalue + "</span>";


.GetLink { text-decoration: underline; cursor: pointer; }

Instead of usage $('.GetLink').click, which register separate click-handler for every hiperlink, I'd recommend you to use one click-handler on the grid. jqGrid register already such click-handler and allows to use your custom actions with respect of beforeSelectRow callback. It saves memory of the web browser and allows to make binding once instead of reapplying binding after every reloading of the grid. See the answer for more details.

Other answers, which could be helpful for you: this one and this one.