Forum


23:06

13/06/2009

Hi,
Been searching for a while and am getting closer but think it's time to ask for help on this one.
I have a grid I fill with initial values from a local array. While I'd like to set the rowid to the same as the array's index for each row it seems that it's not possible to set the first one as rowid=0 so I've got used to the idea of having rowid = array_index +1. (If it is possible to synch them together that would be great).
However that's not really the main question. I've run into the issue of the rowid being set to +1 from the rowcount when adding a new row via editGridRow(new) and if I've deleted a row before I get duplicate rowids.
It seems I should be using AfterSubmit but I'm not sure how or whether that would work for local data. What I want to do is set the rowid for the new record to a specific number. Can someone help me as to how this should be done.
Also will this new rowid be the one that would be used in the subsequent afterInsertRow function I have - or will it be the one that is automatically assigned?
Hope that makes sense and someone will take pity on my hopelessness.
Thanks
Romyn
06:22

Moderators
30/10/2007

Hello Romyn,
Thanks again for your investigationns.
Also you are right there is a problem when we want to insert rowid = 0 in addRowData method. Also corrected in GitHub. Thanks.
Now about your problem.
IMHO it is a good idea in your case to have a global counter for the length of the rows in the grid. That is after you insert the data you can do
mycounter = myarray.length, where the myarray is a data added in the grid.
Then you can use afterSubmit event like this
afterSubmit : function (data, postdata) {
mycounter++;
return [true,"",myconter];
}
This way you will have in all cases uniquie id instead that you delete something from the grid.
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.
Most Users Ever Online: 715
Currently Online:
50 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