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
"saveRow" method does not honor "oper"
18/04/2013
17:37
Avatar
snoopy
Member
Members
Forum Posts: 15
Member Since:
05/03/2012
sp_UserOfflineSmall Offline

Hi everybody,

in InlineEditing when adding a row with "addRow" Method and "keys:true" and afterwards hitting "Enter" the "oper" – property in the AJAX Call correctly contains  "add":

Screenshot

When using the "saveRow" – method after adding a row with "addRow" the "oper" – property in the AJAX Call contains "edit":

Screenshot

Seems to be a Bug ;)

Here is the code regarding the screenshots:

JS:

....

$('#add')
    .button()
    .click(function() {
        $('#test').jqGrid(
                'addRow',
                {
                    addRowParams: {
                        keys:true
                    }
                }
                );
    });

    $('#edit')
        .button()
        .click(function() {
            $('#test').jqGrid(
                    'editRow',
                    $('#test').jqGrid('getGridParam','selrow'),
                    {keys:true}
            );
        });
    
    $('#save')
        .button()
        .click(function() {
            $('#test').jqGrid('saveRow',$('#test').jqGrid('getGridParam','selrow'));
        });

....

HTML:

<table id="test"></table>
<button id="add" type="button">Add</button>
<button id="edit" type="button">Edit</button>
<button id="save" type="button">Save</button>
18/04/2013
19:28
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

If I undersnad you correctly you describe the bug which I reported here. The bug fix is commeted here. So the bug is fixed in jqGrid 4.4.5. If you use jqGrid in the version less then 4.4.5 you need just upgrade your code.

Best regards
Oleg 

18/04/2013
22:03
Avatar
snoopy
Member
Members
Forum Posts: 15
Member Since:
05/03/2012
sp_UserOfflineSmall Offline

As I downloaded jqGrid a few days ago and as you can see here:

Version

I AM currently using jqGrid 4.4.5, so the bug seems NOT to be fixed..

18/04/2013
22:09
Avatar
snoopy
Member
Members
Forum Posts: 15
Member Since:
05/03/2012
sp_UserOfflineSmall Offline

I re-read your post and "my bug" is not exactly the same you described.

In my case, using the method "saveRow" ALWAYS sends oper="edit" to the server but in case of a new added row with "addRow" it should send oper="add"...

18/04/2013
23:33
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

In the case there are misunderstanding. saveRow is old method. It should really always send oper=edit to the server if no other oper property are defined inside of extraparam option of saveRow method.

Inline editing don't suppurt currently any options assosiated with editing row. So I personally prefer usage of editRow with keys: true option. I never call saveRow explicitly in my code. In the way editRow calls internally with the options which I specified for editRow when the user press ENTER key.

If you use saveRow method you are responsible to call it with the correct options. For example you can first test the class of the row which you need to save. If it has class jqgrid-new-row then the row was created by addRow method. In the case you can call saveRow and include {oper: "add"} as the extraparam option of saveRow method. I recommend you to examine the code of inlineNav in the body of if(o.save) {...}. It does exactly what I described.

If you want that this do saveRow internally it will be feature request and not a bug report.

Best regards
Oleg 

19/04/2013
13:09
Avatar
snoopy
Member
Members
Forum Posts: 15
Member Since:
05/03/2012
sp_UserOfflineSmall Offline

>In the case there are misunderstanding. saveRow is old method. It should really always send oper=edit to the server if no

> other oper property are defined inside of extraparam option of saveRow method.

OK, I think that would be worth mentioning in the docs as there one can nowhere read about that it is even POSSIBLE to "overwrite" such an internal generated property as "oper" is.

>Inline editing don't suppurt currently any options assosiated with editing row. So I personally prefer usage of editRow with  

> keys:true option.

When you have a textarea/multiline textbox in InlineEditing pressing Enter in it generates a new Line in the textarea and doesn't trigger the InlineEditing saving action.... or is there a way to redefine the "saving key" from "Enter" to "CTRL-S" for example?

>I never call saveRow explicitly in my code. In the way editRow calls internally with the options which I specified for

>editRow when the user press ENTER key.

Then I'm wondering why this method exists at all and why it es explicitly mentioned in the docs in the "InlineEditing" Section...

Till today I assumed, that one can either call "saveRow" manually or that it (=exactly the same) is triggerd by hitting "Enter" and "keys:true"... so in the last case jqGrid internally calls a completely different method and does not exactly the same than "saveRow" does? Why? Not very consitent, is it? I normally would expect, that an action ("Save this row" in this case) always leads to exact the same behaviour/result no matter what it is used to trigger it...

>If you want that this do saveRow internally it will be feature request and not a bug report.

As mentioned above, "saveRow" is described explicitly in the "InlineEditing" section.

That jqGrid behaves different if saving a row fired by "keys:true" and "pressing Enter" or fired by a manual call of "saveRow" is IMHO not very consistent... and that this is even not mentioned in the docs turns things even worse, I think...

And as a plus: one has to check jqGrid - internal used / generated classnames by oneself for deciding if a row is added or edited despite jqGrid is able to do that by itself already as it does with the "keys:true" - thing? What if jqGrid devs rename the class name? Then you have to refactor all code... (BTW: already happend for example when adding a new row, the "id-prefix" of every input element in the row changed from "new_row" to "jqg[0-9]*")

19/04/2013
13:41
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

In my last post I tried to explain you the current state of inline editing. Nothing is perfect in the world and jqGrid in not an exception: documentation, code, design... 

Many things you can do yourself: improve wiki documentation of jqGrid, post pull request with improvements of jqGrid code and so on. I do myself such things regulary.

I agree with many remarks or suggestions which you wrote, but I can repeat, that in my opinion you described not a bug in jqGrid. You just used saveRow in a wrong way (I mean the existing not perfect inline editing which we all use).

Best regards
Oleg

19/04/2013
13:53
Avatar
snoopy
Member
Members
Forum Posts: 15
Member Since:
05/03/2012
sp_UserOfflineSmall Offline

>In my last post I tried to explain you the current state of inline editing. Nothing is perfect in the world and jqGrid in not an

>exception: documentation, code, design…

Sure I'm absolutly with you and that jqGrid is functioning the way it does till today with that many functionalities is great (and a LOT of work as I can imagine)... one - as a "user" of jqGrid - simply has to know about such "specialities"...

>Many things you can do yourself: improve wiki documentation of jqGrid, post pull request with improvements of jqGrid code and

>so on. I do myself such things regulary.

I could have a try understanding the jqGrid code so far not sure if I'm deep enough in pure / hardcore JavaScript developing even if I would not call myself a newbie 😉 Will have a try where / with what I could help...

Greetings also from Germany as I noticed only now 😉

19/04/2013
16:31
Avatar
snoopy
Member
Members
Forum Posts: 15
Member Since:
05/03/2012
sp_UserOfflineSmall Offline

Just to complete this post:

I solved it as you suggested with this code modifications in my example:

    $('#save')
        .button()
        .click(function() {
            rowid=$('#test').jqGrid('getGridParam','selrow');
            $('#'+rowid).hasClass('jqgrid-new-row') ? oper="add" : oper="edit";
            $('#test').jqGrid('saveRow',
                    rowid,
                    {"extraparam" : {"oper":oper}
            });
            
        });

Thx a lot for your assistance

25/09/2013
20:02
Avatar
mangamuri
New Member
Members
Forum Posts: 1
Member Since:
24/09/2013
sp_UserOfflineSmall Offline

Hi

I am also implementing same in my code.

But whenever i use this line

$('#'+rowid).hasClass('jqgrid-new-row') ? oper="add" : oper="edit";

It always gives me edit, am i missing anything here?

Please help

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
42 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