Forum


12:04

10/08/2009

Hi, jackysee!
If you want to send to server id=0 instead of id=_empty, I'll recomend you use serializeEditData. As input serializeEditData receive data, which jqQuery plan to send. You can construct another data based on input data and return it. Using serializeEditData you don't modify any internal jqGrid data, so you have no side effects compares with any kind of data modification inside of onclickSubmit.
Best regards
Oleg
06:09

22/03/2009

I found that there is a side effect either I use onclickSubmit or serializeEditData. In the settings, I have closeAfterAdd: true, but the dialog does not close after add. The code is like:
closeAfterAdd: true,
url: '/remote.rpc?acton=add',
serializeEditData: function(data){ data.id = 0; return $.param(data);} //dialog not close after add
But strangely if I do not modify the 'data' object, the dialog can be closed successfully! i.e.
closeAfterAdd: true,
url: '/remote.rpc?acton=add',
serializeEditData: function(data){ return $.param(data);} //dialog close after add
This is really strange. Any workaround on this?
06:29

22/03/2009

Digging into the source code found that in postIt(), it has something like:
if(postdata.id=="_empty" ) {
which occurs after serializeEditData, so I changed it to
if(postdata.oper=="add" ) {
and closeAfterAdd works as expected. Any other impact if I apply this change?
13:02

10/08/2009

Hi!
First of all about serializeEditData(). If you look inside of postIt() you can see
$.ajax( $.extend({
url:gurl,
type: rp_ge.mtype,
data: $.isFunction(rp_ge.serializeEditData) ? rp_ge.serializeEditData(postdata) : postdata,
complete:function(data,Status){
…
So if you don't modify postdata inside of your serializeEditData implementation, but make a copy (a clone) of all data instead, makes modification of the copy of postdata, and then return the copy, you receive NO side effects.
By the way, to make a copy of data, which has no subobjects you can do following
var destObj = {};
for (prop in srcObj)
destObj[prop] = srcObj[prop];
Probably exist a nice version to produce a clone of data, but this one works.
Problem with "closeAfterAdd: true", which you describe, is an old bug inside of jqGrid. I had the problem also. But if you set both "closeAfterAdd: true" and "closeAfterEdit: true" everything will work. In all my project I use either both closeAfterAdd and closeAfterEdit as true or both as false, so I have no real problem. But to fix the problem, place it in the forum for bugs.
Best regards
Oleg
Most Users Ever Online: 715
Currently Online:
61 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