Forum
18:44
15/08/2012
I am trying to add an additional value to the POST I send after editing a row. The editable column values all show up in the request when I check in the servlet but 'empId' which is not editable does noit show up. I tried adding it with editData and have had no luck. The code is below:
<!DOCTYPE html>
<html>
<head>
<title>jqGrid Template</title>
<link rel="stylesheet" href="css/jquery.ui.theme.css" />
<link rel="stylesheet" href="css/ui.jqgrid.css" />
<script src="js/jquery.js"></script>
<script src="js/grid.locale-en.js"></script>
<script src="js/jquery.jqGrid.min.js"></script>
</head>
<body>
<table id="grid"></table>
<div id="pager"></div>
<script>
$("#grid").jqGrid({
datatype: "json",
url: "LoadJsonDataServlet?type=BS21 7RH",
pager: "#pager",
mType: 'POST',
colModel:[
{name:'empId', width:100, editable:false},
{name:'firstName',width:100, editable:true},
{name:'lastName', width:100, editable:true},
{name:'address', width:500, editable:true}
],
editurl: "UpdateDataServlet"
});
$("#grid").jqGrid("navGrid", "#pager",
{ add: true,
edit: true,
del: false,
search: false,
refresh: false,
edit : {
addCaption: "Add Record",
editCaption: "Edit Record",
bSubmit: "Submit",
bCancel: "Cancel",
bClose: "Close",
saveData: "Data has been changed! Save changes?",
bYes : "Yes",
bNo : "No",
bExit : "Cancel",
editData:{
EmpId: function(){
var sel_id = $("#grid").jqGrid("getGridParam", 'selrow');
var value = $("#grid").jqGrid("getCell", sel_id, 'empId');
return value;
}
}
}
},
{recreateForm: true,
closeAfterEdit: true,
modal:true}
);
</script>
</body>
</html>
12:26
Moderators
30/10/2007
Hello,
editData is a option where you add a values usually only once when the formeditiong is initialized.
In your case you will need to use serializeEditData event in for editing. See the doc.
This should look something like this:
$("#grid").jqGrid("navGrid", "#pager",
{ add: true,
edit: true,
del: false,
search: false,
refresh: false,
// edit
{
serializeEditData : function(postdata) {
// calculate the id and do
postdata.EmpID = value;
return postdata;
}
}
...
);
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
45 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66