I'm using jqgrid formatoptions for both inline Edit and Del actions. The edit section works very well. But I'm suffering from using the delete button in the way that will not show the default confirmation messagebox.
I was able to manage hidding the default message box by removing the style from delmodtable_list_1 in the afterShowForm section as shown below
formatoptions: {
keys: true,
delOptions:
{
ajaxDelOptions: { contentType: "application/json" },
reloadAfterSubmit: true,
showDialog:false,
closeAfterDelete: true,
keys: true,
beforeShowForm: function (rowid) {
alert('Test'); // it is working
//get row ID
//calling delete controller in here
var row = $(this).closest("tr");
var id = row.attr("id");
//id returns undefined *** Not working
},
afterShowForm: function (row) { // hiding the default delete confirmation messagebox from the user
$('#delmodtable_list_1').removeAttr('style');
$('.ui-widget-overlay').prop('hidden', true);},
}
}
Now I want to use ajax to call the controller after clicking on the inline delete button. But I need also to return the row ID from the SID column which was set as key:true in the column sections of my jqgrid. I used the following code but the id returned undefined.
var row = $(this).closest("tr");
var id = row.attr("id");
Only the first message box alert('Test'); will be triggered without displaying the delete confirmation messagebox.
I don't want to use customs buttons nor having extra columns for delete button. I want to continue with my current solution which is the inline del button without a confirmation messagebox.
I can suggest you to add your own custom button using the navButtonAdd method. Here you can do what you want and you can get the id of the selected row for deletion using a very simple code like this
The same code can be used in your beforeShowForm event
The sellarrrow parameter return the current selected id or null if none selected.
(I checked and see the the beforeShowForm event has only one parameter and it is not the id.)