Reputation: 179
I have new UI where inside jqgrid column there is icon ,if I click it I need to hit on function.
formatter: function (cellvalue, options, rowobject) {
return '<div class="text-center email_production">' +
'<a data-toggle="modal" data-target="#toMailModal" class="icon_color pr-2" ><i class="fa fa-envelope"></i></a>' +
'</div>';
}
where to implement onclick function
Upvotes: 0
Views: 66
Reputation: 3277
Since the formatter should return string you can by example add onclick="myFunction()" in the definition or after the grid data is loaded to (use gridComplate event) to bind a function to the element with certain class
for the first case
formatter: function (cellvalue, options, rowobject) {
return '<div class="text-center email_production">' +
'<a data-toggle="modal" onclick="myFunction()" data-target="#toMailModal" class="icon_color pr-2" ><i class="fa fa-envelope"></i></a>' +
'</div>';
}
and define your global myFunction()
For the second case
$("#jqGrid").jqGrid({
....
gridComplete : function() {
$(".pr-2").on("click", function(){
// do whatever you want
});
}
...
});
Where pr-2 is a class of the a href element
Upvotes: 1