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
Inline mode and session expired problem
23/07/2008
04:49
Avatar
josepk
Member
Members
Forum Posts: 44
Member Since:
16/06/2008
sp_UserOfflineSmall Offline

Hi,

I have instaled the 3.2 version, I have a problem with the inline mode

editing:

When the grid is loaded and the session expired, then when you just

modify a row and it makes a call for saving to the server, it responds

with a header (404) and a page of error, but the jgrid isnt saying anything.

I have tryed to catch these errors with :

succesfunc,

aftersavefunc,

onerrorfunc,

but anything of these arent called when the session is expired and the row
makes a call to the server for saving the changes.
I see that in firebug the server responds with the page of error and it is
of red color indicating that the call is wrong.
But these functions are never called. I have tryed too with (500 error
header).

I need to catch this situation..... but my ideas have been expired....

Something idea?

thanks.
Josep Esofet



23/07/2008
08:25
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

How do yo call onerrorfunc?

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.

24/07/2008
02:20
Avatar
josepk
Member
Members
Forum Posts: 44
Member Since:
16/06/2008
sp_UserOfflineSmall Offline

Hi Tony,

I have been another test, when I modify a row and the row is saved to

the server, I am throwing and error(404) with java

( response.sendError(404) ) and the onerrorfunc is not called.

But my application detects it and send to the client a page with the custom

error for 404, but the grid doesnt catch it.

I am calling the onerrorfunc :

jQuery(grid).editRow(actualRow, true, null, errorAjaxServer, url, null, checkSave, onErrorServer);

jQuery(grid).saveRow(actualRow, errorAjaxServer, url, null, checkSave, onErrorServer);

function onErrorServer(rowid, result){
    alert(rowid +" ---> "+result);
}

I send you the firebug headers :

tanks.

Encabezados de la Respuesta
Server Apache-Coyote/1.1
Content-Type text/html;charset=ISO-8859-1
Transfer-Encoding chunked
Date

Thu, 24 Jul 2008 07:11:31 GMT

Encabezados de la Solicitud
Host localhost:8080
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
Accept */*
Accept-Language es-es,es;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
Content-Type application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With XMLHttpRequest
Referer http://localhost:8080/previsor.....LTORES+S.L.
Content-Length 36
Cookie JSESSIONID=20CDA64E387CCEE86A27DBF0FC16A080
24/07/2008
02:23
Avatar
josepk
Member
Members
Forum Posts: 44
Member Since:
16/06/2008
sp_UserOfflineSmall Offline

I send again the functions.

jQuery(grid).editRow(actualRow, true, null, errorAjaxServer,

url, null, checkSave, onErrorServer);

jQuery(grid).saveRow(actualRow, errorAjaxServer, url,

null, checkSave, onErrorServer);

function onErrorServer(rowid, result){
    alert(rowid +" ---> "+result);
}

24/07/2008
02:44
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Yes the server detect this and return a regular html page

which is interpreted normal in jqGrid.

You should detect that session is expired and

send the appropriate headers so that jqGrid

can interpret this. I think there was such

post in the forum

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.

24/07/2008
03:10
Avatar
josepk
Member
Members
Forum Posts: 44
Member Since:
16/06/2008
sp_UserOfflineSmall Offline

I think that this is not the problem, with my last test , I

have the session active, and I forced an error on every row

save, with a header(404) or (500) and the function onerrorfunc

is never called, then I look at inline.js and I have found :

$.post(url,tmp,function(res,stat){ function on saveRow.

I have looking at documentation on jquery and I have

found that :

This is an easy way to send a simple POST request to a server

without having to use the more complex $.ajax function. It

allows a single callback function to be specified that will be executed

when the request is complete

(and only if the response has a successful response code).

then in case of error (404, 500,...) the onerrorfunc is never called.

is it ok? Is it a bug?

thanks.

24/07/2008
03:24
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Simple - if you have FireBug you can easy look what is returned

from the server.

In inline edit there is a line

$.post("someurl", function(request,status) {

if(status=='success') {

....

This mean that the status returned from the server has a

value success.

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.

24/07/2008
04:23
Avatar
josepk
Member
Members
Forum Posts: 44
Member Since:
16/06/2008
sp_UserOfflineSmall Offline

Hi tony,

I have look the code again and I think that your solution is

wrong becouse the callback function is never called if the

response of the server is not success, then the if into the function

that says : if (stat === "success"){ is never called if the response

is wrong becouse the callback function is never called.

I have tested it and if the response is success the function is

called, but if it is wrong (404, 500....) the function is never called,

just put an alert before if (stat === "success") and you will see that

the function is never called.

thanks,  I am going to see in the documentation of jquery to use

another ajax call that catch the error.

24/07/2008
06:21
Avatar
josepk
Member
Members
Forum Posts: 44
Member Since:
16/06/2008
sp_UserOfflineSmall Offline

Hi Tony,

I have found the solution, now I am cleaning the code and doing

the last test... and after I will post the solution.

The key is not to use $.post function becouse this function

doesnt call the callback function in case of the response is not success,

then if you use the $.ajax fucntion with onerror: callback function.

I have tested the first solution and it works.

When I finished the code I will post, perhaps later or tomorrow.

this solution catches the session expired too.

thanks.

Josep escofet

24/07/2008
07:18
Avatar
josepk
Member
Members
Forum Posts: 44
Member Since:
16/06/2008
sp_UserOfflineSmall Offline

Hi,

I have finished the solution and I posted here, I put the full complet

saveRow function, the only think that I have made is to change the

call to $.post for $.call and clean some code not necessary.

This functions resolves the problem of session expired when

you are going to make a row to save and if there is a problem

saving row on server and it responds with some error code

(400, 404,500....) not 200 OK code.

saveRow : function(rowid, succesfunc, url, extraparam, aftersavefunc,errorfunc) {
        return this.each(function(){
        var $t = this, nm, tmp={}, tmp2, editable, fr;
        if (!$t.grid ) return;
        editable = $('#'+rowid,$t.grid.bDiv).attr("editable");
        url = url ? url : $t.p.editurl;
        if (editable==="1" && url) {
            $('#'+rowid+" td",$t.grid.bDiv).each(function(i) {
                nm = $t.p.colModel[i].name;
                if ( nm !== 'cb' && nm !== 'subgrid' && $t.p.colModel[i].editable===true) {
                    if( $t.p.colModel[i].hidden===true) tmp[nm] = $(this).html();
                    else if( $t.p.colModel[i].edittype==='checkbox') tmp[nm]=  $("input",this).attr("checked") ? 1 : 0;
                    else tmp[nm]= $("input, select>option:selected, textarea",this).val();
                }
            });
            if(tmp) { tmp["id"] = rowid; if(extraparam) $.extend(tmp,extraparam);}
            if(!$t.grid.hDiv.loading) {
                $t.grid.hDiv.loading = true;
                $("div.loading",$t.grid.hDiv).fadeIn("fast");
                $.ajax({
                       type: "POST",
                       url: url,
                       data: tmp,
                       error: function (XMLHttpRequest, textStatus, errorThrown) {
                           if(typeof errorfunc == "function") {
                                errorfunc(XMLHttpRequest.responseText,textStatus+": "+XMLHttpRequest.status);
                            } else {
                                alert("Error Row: "+rowid+" Result: " +res+" Status: "+stat);
                            }
                         },
                       success: function(res,stat){
                        var ret;
                        if( typeof succesfunc === "function") ret = succesfunc(res);
                        else ret = true;
                        if (ret===true) {
                            $('#'+rowid+" td",$t.grid.bDiv).each(function(i) {
                                nm = $t.p.colModel[i].name;
                                if ( nm !== 'cb' && nm !== 'subgrid' && $t.p.colModel[i].editable===true) {
                                    switch ($t.p.colModel[i].edittype) {
                                        case "select":
                                            tmp2 = $("select>option:selected", this).text();
                                            break;
                                        case "checkbox":
                                            var cbv = $t.p.colModel[i].editoptions.value.split(":") || ["Yes","No"];
                                            tmp2 = $("input",this).attr("checked") ? cbv[0] : cbv[1];
                                            break;
                                        case "text":
                                        case "textarea":
                                            tmp2 = $("input, textarea", this).val();
                                            break;
                                    }
                                    $(this).empty();
                                    $(this).html(tmp2 || " ");
                                }
                            });
                            $('#'+rowid,$t.grid.bDiv).attr("editable","0");
                            for( var k=0;k<$t.p.savedRow.length;k++) {
                                if( $t.p.savedRow[k].id===rowid) {fr = k; break;}
                            };
                            if(fr >= 0) $t.p.savedRow.splice(fr,1);
                            if( typeof aftersavefunc === "function") aftersavefunc(rowid,res);
                        } else $($t).restoreRow(rowid);
               
                }
                     });
                $t.grid.hDiv.loading = false;
                $("div.loading",$t.grid.hDiv).fadeOut("fast");
                $("#"+rowid,$t.grid.bDiv).unbind("keydown");
            }
        }
        });

thanks.

Josep Escofet

24/07/2008
07:21
Avatar
josepk
Member
Members
Forum Posts: 44
Member Since:
16/06/2008
sp_UserOfflineSmall Offline

The code is not all visible on the screen , there is some method for post the

code correctly ?

Tony, do you want to put this for all?

thanks.

Josep Escofet

25/07/2008
01:50
Avatar
josepk
Member
Members
Forum Posts: 44
Member Since:
16/06/2008
sp_UserOfflineSmall Offline

If somebody wants de grid.inline.js modified ask me , and I send my

copy with the problem of onerrorfunc solved(session expired,

error saving on server) and with another

function afterCancelFunc a callback function that is called when

the ESC key is pressed on a row.

josepk.basura@gmail.com

thanks.

Josep Escofet

25/07/2008
02:14
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hi Josep,

You can send me the code to tony at trirand.com

Thank you

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.

25/07/2008
02:32
Avatar
josepk
Member
Members
Forum Posts: 44
Member Since:
16/06/2008
sp_UserOfflineSmall Offline

Ok tony,

I have sended you the grid.inline.js.

thanks.

Josep Escofet

25/07/2008
03:02
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Thanks

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:
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.com

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information