I\'m trying to call a function in the onclick event of the button that is created during the gridComplete event..Loads OK…here\'s what the rendered html looks like for the b
I would change your grid complete function so that it gives the imput a class of say "delete" and then in my document ready function setup a live click event for that class selector.
something like this
gridComplete: function() {
var ids = jQuery("#list").jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++) {
var cl = ids[i];
de = '<input style="height:22px;width:70px;" type="button" class="delete" value="Delete" />';
$("#list").jqGrid('setRowData', ids[i], { Delete: de });
}
}
$('#list .delete').live('click',function(){
var id = $(this).parent().attr('id');
});
You could define deleteRow
as a custom jQuery function, and then call it on selected elements.
$.fn.deleteRow = function() {
row_id = $(this).attr('id');
return $("#grid_id").jqGrid('delGridRow', row_id);
}
Call it like this:
$("#grid_id button[value=Delete]").click( function() {
$(this).parents('.row_class').deleteRow();
});
I'd imagine that would need to be more complex--I'm not familiar with jqGrid, but what you need to do is pretty straightforward.
Could you post some markup? It's difficult to tell how to select the row by ID without seeing it.