I have created a jQgrid and want it to call a callback function once a new row is added or some content is edited in the grid
jQuery("#list1").jqGrid({
url: '/testGrid/sample?q=5',
datatype: "json",
mtype: 'POST',
jsonReader: {
page: "page",
total: "total",
root: "rows",
records: "records",
repeatitems: false,
cell: "name",
userdata: 'userdata'
},
width: 775,
colNames: ['Salaried Employees', '# of FTEs', 'Budget', 'Actuals to Date', 'Invoice Salary'],
colModel: [
{name:'salEmp',index:'salEmp', width:100, align: 'left', width:100,editable:false,editrules:{required:true}},
{name:'FTE',index:'FTE', width:100, align: 'center', editable:false,required:true,editrules:{required:true,number:true}},
{name:'Budget',index:'Budget', width:100, align: 'right', width:100,editable:false,required:true,editrules:{required:true,number:true}},
{name:'actDate',index:'actDate', width:100, align: 'right', align:"right",editable:false,required:true,editrules:{required:true,number:true}},
{name:'invSal',index:'invSal', width:100, align:"right",editable:true,required:true,editrules:{required:true,number:true}}
],
rowNum: 5,
rowList: [5, 10, 20],
autoencode: true,
ignoreCase: true,
sortable: false,
height: '100%',
pager: jQuery('#pager1'),
cellEdit: false,
cellsubmit: 'remote',
//cellurl: '/testGrid/sample',
//call onclick of save
editurl:"/testGrid/sample",
gridview: true,
reloadAfterSubmit:true
})
// Pager options for Subgrid
.navGrid('#pager1',{
add:false,
edit:false,
del:true,
search:false,
refresh:false,
deltext: 'Delete'
});
$('#list1').jqGrid('inlineNav','#pager1',{
addtext: "Add",
edittext: "Edit",
savetext: "Save",
canceltext: "Cancel",
addParams: {
position: "afterSelected"
},
addedrow:'last'
});
I have created a jQgrid and want it to call a callback function once a new row is added or some content is edited in the grid
jQuery("#list1").jqGrid({
url: '/testGrid/sample?q=5',
datatype: "json",
mtype: 'POST',
jsonReader: {
page: "page",
total: "total",
root: "rows",
records: "records",
repeatitems: false,
cell: "name",
userdata: 'userdata'
},
width: 775,
colNames: ['Salaried Employees', '# of FTEs', 'Budget', 'Actuals to Date', 'Invoice Salary'],
colModel: [
{name:'salEmp',index:'salEmp', width:100, align: 'left', width:100,editable:false,editrules:{required:true}},
{name:'FTE',index:'FTE', width:100, align: 'center', editable:false,required:true,editrules:{required:true,number:true}},
{name:'Budget',index:'Budget', width:100, align: 'right', width:100,editable:false,required:true,editrules:{required:true,number:true}},
{name:'actDate',index:'actDate', width:100, align: 'right', align:"right",editable:false,required:true,editrules:{required:true,number:true}},
{name:'invSal',index:'invSal', width:100, align:"right",editable:true,required:true,editrules:{required:true,number:true}}
],
rowNum: 5,
rowList: [5, 10, 20],
autoencode: true,
ignoreCase: true,
sortable: false,
height: '100%',
pager: jQuery('#pager1'),
cellEdit: false,
cellsubmit: 'remote',
//cellurl: '/testGrid/sample',
//call onclick of save
editurl:"/testGrid/sample",
gridview: true,
reloadAfterSubmit:true
})
// Pager options for Subgrid
.navGrid('#pager1',{
add:false,
edit:false,
del:true,
search:false,
refresh:false,
deltext: 'Delete'
});
$('#list1').jqGrid('inlineNav','#pager1',{
addtext: "Add",
edittext: "Edit",
savetext: "Save",
canceltext: "Cancel",
addParams: {
position: "afterSelected"
},
addedrow:'last'
});
Share
Improve this question
edited Nov 24, 2019 at 21:27
halfer
20.4k19 gold badges109 silver badges202 bronze badges
asked Jan 14, 2013 at 11:45
VarunVarun
5,05112 gold badges56 silver badges86 bronze badges
4
- The code which you posted don't contain any editing. The answer on your question depend on which editing mode you want to use: cell editing, inline editing or form editing. Additionally jqGrid provide many options of usage of inline editing and form editing like inlineNav, formatter: "actions" etc. – Oleg Commented Jan 14, 2013 at 12:03
- The callbacks which you need are different for different kind of editing modes and different implementation variants. So you have to decide first which editing mode and which implementation version more corresponds the requirements of your project. – Oleg Commented Jan 14, 2013 at 12:04
- @Oleg - i will be using cell based editing eventually this is more of POC to explore jQgrid – Varun Commented Jan 14, 2013 at 12:43
- What is "POC"? As I wrote before every implementation of editing provide callbacks, but the callbacks are different. So if you decide to use cell editing instead you need use another callbacks. Moreover you should specify more exact at what moment you need your callback by called: before editing started, directly after started, before saving, after saving etc. – Oleg Commented Jan 14, 2013 at 12:53
1 Answer
Reset to default 8inlineNav
allows to specify the callbacks of editRow used for inline editing. To specify the callbacks one can use editParams
and addParams.addRowParams
options:
var myEditOptions = {
keys: true,
oneditfunc: function (rowid) {
alert("row with rowid=" + rowid + " is editing.");
},
aftersavefunc: function (rowid, response, options) {
alert("row with rowid=" + rowid + " is successfuly modified.");
}
};
$('#list1').jqGrid('inlineNav','#pager1', {
addtext: "Add",
edittext: "Edit",
savetext: "Save",
canceltext: "Cancel",
addParams: {
position: "afterSelected",
addRowParams: myEditOptions
},
addedrow: "last",
editParams: myEditOptions
});