This is my jqGrid handler.
var myEditParams = {
keys: true,
extraparam: {
ajax: function () {
alert("in myEditParams:extraparam");
return "1";
}
}
};
var lastsel;
jQuery("#list2").jqGrid({
data: data,
height: 250,
emptyDataText: "No Records Found",
width: $('#mainwrapper').width(),
datatype: "local",
colNames:['Table Description','Display Table name'],
colModel:[
{ name:'table_desc', index:'table_desc', sortable: false, align: 'left', editable: true, edittype: 'text', editoptions:{ size:40 }, formatoptions:{
keys: true,
editOptions: myEditParams
} },
{ name:'display_table_name',index:'display_table_name', sortable: false }
],
loadComplete: function(){
$('.ui-jqgrid-htable').css('width',$('#mainwrapper').width()+'px');
if ($('#list2').getGridParam('records') == 0){ // are there any records?
DisplayEmptyText(true);
}else{
DisplayEmptyText(false);
}
},
rowNum:10,
rowList:[10,20,30],
pager: '#pager2',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"Changelog Tables",
postData: { ajax: "1" },
onSelectRow: function(id){
if(id && id!==lastsel){
jQuery('#list2').jqGrid('restoreRow',lastsel);
jQuery('#list2').jqGrid('editRow',id,true);
$('#list2').jqGrid('setGridParam',id,{ ajax:"1" }); //wanted to set some custom params here.
lastsel=id;
}
},
editurl: "changeLog.php"
});
I want to send one extra param as ajax=1, when I do some in-place edit operation. I have tried every way. But nothing seems to work. I am almost frustrated.
I tried this:
$("#list2").jqGrid('setGridParam',{postData:{ajax:'1'}});
Didn’t work. I also tried setting postData param as you can see in the handler. That too is not working. What is going wrong here? Please help me with this
The method editRow supports
extraparam. So you can rewriteonSelectRowso:By the way you can use methods (functions) instead of properties in the
extraparam. It can be helfull in the following case. The values likeextraparam: { ajax: $("#myControl").val() }will be calculated at the moment of the call theeditRowfunction. If you would be useextraparam: { ajax: function () { return $("#myControl").val(); } }then the value ofajaxparameter will be evaluated at the moment of saving of the value. At the moment the$("#myControl").val()can have another value.