I have a jqGrid that I am adding a new row to that the user can edit. They have a button to save the new row. I need to get to the ajax beforeSend to stuff some security into the call. This is working in several other scenarios with the grid, but, not this one. Not sure what is going on.
Here is how I am adding the new row:
jQuery("#myTable").jqGrid('addRow',{
rowID : "new_row",
initdata : {},
position :"first",
useDefValues : false,
useFormatter : false,
addRowParams : {extraparam:{}});
Here is my the code executed by my save button:
jQuery("#myTable").jqGrid('saveRow',"new_row", {
"url": "{{path('recording_create')}}",
"mtype": "POST",
"succesfunc": function(response) {
return true;
}
});
I tried this, but, it is not fired. I thought this would be called when saving a row:
$.extend($.jgrid.defaults,
{
ajaxRowOptions: {
beforeSend: function () {
alert('Before Row Send'); // not called
}
},
}
);
I also tried this, but, I think this is only called on form editing?
$.extend($.jgrid.edit, {
ajaxEditOptions: {
beforeSend: function (jqXHR, settings) {
alert('Before Row Send'); // not called
}}});
Any thoughts?
Thanks, Scott
Oleg, Thanks for the idea. But, that did not work. However, the following does work:
Question for you though, how do you know what can be extended the way you extended above?
Thanks, Scott
You can try to use
I hope it will work.
UPDATED: Sorry, but the correct code
you already included in the text of your question. It should work. It's important only to verify that the code will be executed before the grid is created.