Skip to content Skip to sidebar Skip to footer

How Do You Add Scripts To Custom Buttons On Rows In Jqgrid?

I am trying to handle the click of custom button in a jqgrid. I have the buttons showing up, but when they are clicked, my function does not run. If I click a button outside the jq

Solution 1:

It is apparent that the click event,

$(".sendbuttons").click(function(){
     alert("got to 1");
});

never fires because the click of the row consumes it. You can, however, put in your own onclick code in the button.

send = "<inputname='send'class='tweetbuttons'id='tbuttonSend"+cl+
       "'type='button'value='Send'onclick=jQuery('#list2').saveRow("+cl+",function(){alert('madeithere')},item_send); /><br />"; 

As discussed in my comment, I can call the saveRow function with any parameters.

Solution 2:

Add

$(".sendbuttons").click(function(){
     alert("got to 1");
});

in gridComplete callback and it fires.

loadComplete: function(){ 
    //alert('ok, loadComplete running');var ids = jQuery("#gridlist").getDataIDs();
    for(var i=0;i<ids.length;i++){
        var cl = ids[i];
        send = "<input class='sendbuttons' id='tbuttonSend"+cl+"' type='button' value='Send' /><br />";
        clear = "<input class='sendbuttons' id='tbuttonClear"+cl+"' type='button' value='Send' /><br />";
        jQuery("#gridlist").setRowData(ids[i],{options:send+clear})
 }
    $(".sendbuttons").click(function(){
        alert("got to 1");
    });
},

Post a Comment for "How Do You Add Scripts To Custom Buttons On Rows In Jqgrid?"