Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
apparent afterSubmit inconsistent behaviour
25/10/2008
13:05
Avatar
cjorata
Member
Members
Forum Posts: 4
Member Since:
25/10/2008
sp_UserOfflineSmall Offline

Maybe i'm wrong, but i'm experiencing inconsistent afterSubmit behaviour using

[jqgrid code].navGrid(
"#pagerid",{add:true,edit:true,del:true,search:false,refresh:false},
                {
                    reloadAfterSubmit:true,
                    closeAfterEdit:true,
                    beforeShowForm:function(){alert("beforeShowForm edit");},
                    afterSubmit:function(r,data){alert('afterSubmit edit');}
                }
                ,
                {
                    reloadAfterSubmit:true,
                    closeAfterAdd:true,
                    beforeShowForm:function(){alert("beforeShowForm new");},
                    afterSubmit:function(r,data){alert('afterSubmit new');}
                }
    );

When i click on the edit button i get as expected

1) alert("beforeShowForm edit");
2) alert('afterSubmit edit');

but when i click on the new button i get

1) alert("beforeShowForm new");
2) alert('afterSubmit edit'); <- i expected an alert('afterSubmit new');

trying the opposite (first hit the new button, than the edit button) you can experience the opposite, this time

1) alert("beforeShowForm new");
2) alert('afterSubmit new');

but when i click on the new button i get

1) alert("beforeShowForm edit");
2) alert('afterSubmit new');

... so to make a long story short, it seems that the once the afterSubmit event is initialized with a function you can't change it ...

Maybe someone of you crashed on this problem before ...

I'm trying it on IE7, windows XP, latest jqgrid release (3.3).

Hope i'm wrong and this is not a bug ...

Cheers

CJ

29/10/2008
02:10
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Thank you. Definitley I will check this.

Regards

Tony

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.

29/10/2008
18:00
Avatar
cjorata
Member
Members
Forum Posts: 4
Member Since:
25/10/2008
sp_UserOfflineSmall Offline

Ok after some research i found what could be the reason of this issue:

the reason is how editGridRow is implemented :

editGridRow : function(rowid, p){
        p = $.extend({
            // blah blah blah
        }, $.jgrid.edit, p || {});
        return this.each(function(){
            // various references to p

           $.ajax( // blah blah,

                   complete:function(a,b){

                     // again references to p
                     if ( typeof p.afterSubmit === 'function' )

                             p.afterSubmit(a,b);

                   }

        }

to be short : you can't reference p safely inside this.each and inside complete because it's an out of scope variable, instead if you do something like this (which is pretty raw i know, but it works) ...

var CJ_customglobalvar = null;

editGridRow : function(rowid, p){
        p = $.extend({
            // blah blah blah
        }, $.jgrid.edit, p || {});
        CJ_customglobalvar = p;
        return this.each(function(){
            // various references to p -> become references to CJ_customglobalvar

           $.ajax( // blah blah,

                   complete:function(a,b){

                     // again references to p becomes references to CJ_customglobalvar
                     if ( typeof CJ_customglobalvar.afterSubmit === 'function' )

                             CJ_customglobalvar.afterSubmit(a,b);

                   }

        }

.... so i hope to have suggested you some kind of solution ... for me it worked out ...

Cheers

CJ

31/10/2008
01:26
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Thank you very much for this. It is true.

We should have working solutions 🙂 and I will implement your

correction.

Best Regards

Tony

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.

15/09/2009
03:47
Avatar
paolo
Guest
Guests

i think to have a similar error.

afterSubmit event seems to happen before server calling and i can't receive response data and i've verified that

jQuery(gridName).editGridRow('new',{height:150,reloadAfterSubmit:true,editData:{action:'new',afterSubmit:function(response,postdata){alert(response)}}});

return always undefined even if  server call is completed and database updated.

Paolo.

15/09/2009
12:53
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

1. maybe this will work  afterSubmit:function(response,postdata){alert(response.responseText); return [true,"",""];}}

2. this event should return array with special values - see docs

Regards

Tony

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.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
73 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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information