Forum
17:02
18/11/2009
Hello!
After updating jqGrid to the latest releases (jqGrid 4.3.1, jQuery 1.7.1) and using the new idPrefix option for my grids I detected the following problem:
In some cases the idPrefix is added/used twice for the table rows id attribute (... id="pre_pre_12"). This problem seems to occur when using a grid with local data added via addRowData ...
myTable.jqGrid("clearGridData");
myTable.jqGrid("addRowData", "id", myData);
myTable.jqGrid('sortGrid', 'name', true, 'asc');
jqGrid calls the following internal functions: addRowData and then addJSONData for each row ... I think this is the cause of the problem, why the prefix is added twice.
On the other hand, when using server side data (JSON) the ids are set correctly using the idPrefix only once. (... id="pre_12")
I've solved the problem by checking each time the prefix is appended, if it is already included in the ID and only add it if not.
But I don't think this is a really good solution. Maybe someone who knows the jqGrid code better could provide a clean bugfix for that problem.
Kind regards,
Klaus.
18:31
Moderators
30/10/2007
Hello,
Do you have checked your myData?
Please veryfy that myData does not have any id with like pre_12 before it is added into the grid
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.
19:07
18/11/2009
Hello,
I've verified the data, and it is totally correct, but then I've found the exact position, when the problem happens ... it is the sortGrid call and not the addRowData!
After the data was added with addRowData the ids where still correct, but after calling the sortGrid method the ids got wrong (with double-prefix)!
Here are some more details about my configuration:
idPrefix: "pre_",
datatype: "local",
colModel: [
{label: 'Name', name: 'name', index: 'name', jsonmap: 'name'},
{label: 'ID', name: 'id', index: 'id', jsonmap: 'id'}
]
jsonReader: {
root: "entries",
page: "tablepage",
total: "tablepagetotal",
records: "tablerecords",
repeatitems: false,
id: "id"
},
...
}
myData = [ /* it doesn't matter if the ids are strings or int ... same bahaviour */
{id: "1", name: "test1"},
{id: "2", name: "test2"}
];
myTable.jqGrid('addRowData', "id", myData);
myTable.jqGrid('sortGrid', 'name', true, 'asc');
Kind regards,
Klaus.
15:12
Moderators
30/10/2007
Hello,
I hope that the problem is fixed.
Couild you please let us know which version is used.
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
18/05/2012
I have the latest version (4.3.2) (with no code from github) and I'm also seeing the issue when the grid is sorted. I don't think Klaus actually fixed the issue, he was just pointing where he things the issue happens.
Moreover, I think the issue happens with any reload of the grid (filtering, sorting, etc)
Thanks again tony for such a great plugin.
09:25
18/05/2012
Looks like I answered my own question, or at least a way to make it work. Looks like since I was using json data with loadonce: true, the id lookup for a reload was using the "localReader" id, which defaults to _id_(in our case 'idPrefixxx'). The reload then concatenates the idPrefix with the id retrieved from the row, leading to a duplicated idPrefix. If we use key:true in a col in our model that also represents the id of the row, we are all set, as the reload method will take *that* id instead of the rowid.
I still think there is an issue with how the rowid is constructed, as we should never end up with a duplicated idPrefix
Saludos desde Costa Rica
Max
Most Users Ever Online: 715
Currently Online:
53 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