Forum


16:23

10/01/2013

Hi,
I have configured my jqGrid to have hidden column named "resource_uri".
When editing or deleting I need to send the proper request (PATCH or DELETE) to the address retrieved from edited grid row.
When creating new record, the url is the same as for the list, however there's extra "id" field appended (even though the "id" field is marked in colmodel as not editable!) with value of "_empty" which I need to remove (otherwise my backend raises an error!).
Also, I need to manually delete "oper" field (what if I had "oper" field in my colmodel?!)
for initialization, I'm doing following:
$.extend($.jgrid.edit, { serializeEditData: function(data) { // delete fields which are not part of row data delete data.oper; if (data.id == '_empty') delete data.id; return JSON.stringify(data); } }); $.extend($.jgrid.del, { mtype: 'DELETE', serializeDelData: function() { // send empty DELETE request return ""; } });
now, there are following options for form editing initialization (navGrid):
var delOptions = { onclickSubmit: function(params, postdata) { // retrieve proper url to send request to // a bit tricky since the postdata equals to row id here params.url = $(this).jqGrid('getRowData', postdata).resource_uri; } }; var addOptions = {mtype: "POST"}; var editOptions = { mtype: "PATCH", onclickSubmit: function(params, postdata) { // find out row id // VERY tricky! var row_id = postdata[$(this).attr('id')+'_id']; params.url = $(this).jqGrid('getRowData', row_id).resource_uri; }, }
it's tricky to retrieve the row id. it's also very inconsistent as the "id" attribute (with "_empty" value) is present while creating the record (even though it should not be there!), yet - while editing - it's hard to find out the row id.
also, I don't find the onclickSubmit to be the proper place for providing request url - I suppose it's not fired when doing inline edition (I haven't tried it yet)?
is the API so inconsistent or am I doing it wrong? Any suggestions, please? 🙂
regards, mg
Most Users Ever Online: 715
Currently Online:
41 Guest(s)
Currently Browsing this Page:
2 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