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_Related Related Topics sp_TopicIcon
duplicate rowid produced by addRow
07/11/2012
14:39
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hello Tony,

default parameter of addRow contains rowID: "new_row". As the result the simplest usage of inlineNav with local grid (having editurl: "clientArray") will produce id duplicates if one add multiple rows to the grid with respect of clicking on the "Add" button.

Additional problem is that one can't use function as the value of rowID. So one can't produce unique ids or just different ids in a simple way.

I suggest to fix the code of in the following way (I marked changed places with bold font):

addRow : function ( p ) {
    p = $.extend(true, {
        rowID : undefined,
        initdata : {},
        position :"first",
        useDefValues : true,
        useFormatter : false,
        addRowParams : {extraparam:{}}
    },p  || {});
    return this.each(function(){
        var $t = this,
            rowID = $.isFunction(p.rowID) ? p.rowID.call($t, p) : (p.rowID ? p.rowID : $.jgrid.randId())
;
        ...
        ... in the code below the usage of p.rowID will be replaced to 
        ... the usage of new rowID variable.
        ...
    });
}, 

I changed the default value of rowID to undefined to force call of in case of the simplest usage of addRow method. Additionally the line 

addParams : {useFormatter : false,rowID : "new_row"},

of inlineNav which defines default values of inlineNav should be changed to

addParams : {},

Best regards
Oleg

08/11/2012
10:49
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello Oleg,

Thanks. This is ok.

The only thing for me is that the rowID should be set from undefined to null and we should perform check if

we want to add a row with id = 0, then this p.rowID ? p.rowID : $.jgrid.randId()

will produce bad call of randID.

Regards

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.

08/11/2012
11:15
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hello Tony,

you are right. It's better to use 

(p.rowID == null) ? p.rowID : $.jgrid.randId()

(test for null or undefined) instead of

p.rowID ? p.rowID : $.jgrid.randId()

Regards
Oleg

08/11/2012
11:29
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Thanks Oleg.

Published in GitHub. You maybe mean :

(p.rowID !== null) ? p.rowID : $.jgrid.randId() Wink

Best Regards


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.

08/11/2012
11:38
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Yes, of cause! But I think that it's better to use (p.rowID != null) instead of (p.rowID !== null) to test for not null or not undefined instead of testing for null only.

Regards

08/11/2012
11:59
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Oleg,

Ok. Changed, but I think nobody will set a undefined.

Regards

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.

08/11/2012
13:26
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Sorry, my last suggestion was based on my *original* code where the value of rowID was undefined. One uses $.extend with input parameters. So one can't ovewrite any other value with the undefined value. If you use null as the default value then rowID will never been undefined, but it's not a real problem. So your previous suggestion will work exacly so good as the last one. Sorry for the misunderstanding.

Regards
Oleg

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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