Search code examples
jqueryjqgridfree-jqgrid

Free jqGrid 4.11 - Unformat from http link format during edit


Suppose I'm adding a format to a cell that looks like this:

return '<a href="' + cellvalue + '" target="_blank">Click Here</a>';

Now, if user is trying to 'edit' the cell, he will be presented with the value 'Click Here' for editing, and not with the actual url.

How can I make the actual url appear when user choose to edit this row?

Thanks,

Tal.


Solution

  • You should define unformatter. The code could be the following

    unformat: function (cellvalue, options, elem) {
        return $(elem).children("a").attr("href");
    }
    

    or

    unformat: function (cellvalue, options, elem) {
        return $(elem).find("a").attr("href");
    }
    

    The first parameter of unformat callback is the text from the cell, but the 3-d parameter is the DOM element of parent of <a> which you create by the formatter.