Forum
09:25
27/09/2010
Code to recreate problem:
$("#tableSearch").jqGrid({
datatype: "local",
colNames: ['Type', 'Description', 'Options'],
colModel: [{ name: 'Type', index: 'Type', width: 50, align: "center" },
{ name: 'Description', index: 'Description', width: 230, sortable: true },
{ name: 'Options', index: 'Options', width: 69, sortable: false}],
rowNum: 10,
sortname: 'type',
sortorder: "desc",
id: "RowID",
caption: "Search",
rowList: [10, 20, 30],
pager: "#divPager",
gridComplete: function () {
}
})
});
function GoGoGo() {
$("#tableSearch").clearGridData();
$("#tableSearch").addRowData("RowID", [{ RowID: "101", Type: "Type", Description: "Desc", Options: "Option" }, { RowID: "102", Type: "Type", Description: "Desc", Options: "Option"}]);
$("#tableSearch").trigger("reloadGrid");
var test1 = $("#tableSearch").getDataIDs();
debugger;
//Will return ID of 1 for row 1
}
10:33
27/09/2010
Ok so I worked out what was going on.
The problem is the $("#tableSearch").trigger("reloadGrid"); method. However this must be called
to enable paging to work with local data (It does work fine once this is called)
The problem with the method is it causes a call to the addJSONData method which in turn contains the following line
var dReader = ts.p.datatype == "local" ? ts.p.localReader : ts.p.jsonReader, locid, locdata = (ts.p.datatype != "local" && ts.p.loadonce) || ts.p.datatype == "jsonstring";
this is where the problem is. At this point whatever is set as your localreader id value is now
being used rather then the original rowID value, hence since your object (in my case)
doesnt contain the default value id a new rowid is generated and bammm your old values are
thrown out.
So basically the temp solution to this is to add the following to your original declaration
localReader: { id: "MyRowID"}
But really this is probably a value that should get overwritten in the addRowData method???
Either way its up to you guys to work out…
Hopefully this helps someone
PS: Thanks again for writing this grid… It Rocks…
11:20
27/09/2010
Turns out this problem gets even more interesting. Realized that after all that I had forgotten that during my
testing I added a column in the colModel as such
{ name: 'MyRowID', index: 'MyRowID', hidden: true }
If this column doesnt exist the entire process described above again breaks.
This seems to be a result of the fact that if the column – for the rowid – doesnt exist in the column model it is not
remembered by the grid and stored in the data collection therefore on the second pass (during the reloadGrid method)
it loses the value (again).
Hopefully this makes some sense to you guys
20:10
Moderators
30/10/2007
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:
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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66