The first page of results with a jqgrid rowObject returns expected data but then returns incomplete data for subsequent pages of results. Why?
First page of results: rowObject[3] will equal "2"
Subsequent pages of results: rowObject[3] will equal "undefined" and returning to the first page of results will also now equal "undefined".
More details and some code:
With jqGrid, if you want to implement a custom formatter you use a parameter called rowObject that contains the row data. So for instance, one row of rowObject could be something like:
["18", "133", "Betelguese", "3", "photo.jpg", "", "0", ""]
So my custom formatter uses some of this data to prepare a link as follows:
var newval = '<a href="/proj/' + rowObject[3] + '/images/' + imgval + '">' + imgval + '</a>';
and this gives me a url like:
<a href="/proj/3/images/photo.jpg">photo.jpg</a>
So far so good. My problem is that when I go to the next page of results in the jqgrid I lose some of this data and get:
<a href="/proj/undefined/images/photo.jpg">photo.jpg</a>
If I load the page with all of the results displayed everything works fine, however if I use paging, only the first page of results will have the correct value for rowObject[3] while every other result on subsequent pages will not have that rowObject value!
So why is rowObject containing the correct data on what is initially loaded into the grid and seeming to lose that data when the next page of grid results appears?
One thing I'm seeing in Firebug that I don't understand... when the page initially loads I get:
console.log(rowObject);
["18", "133", "Betelguese", "3", "photo.jpg", "", "0", ""]
On the next page of results, where things stop working as I expect, I see
console.log(rowObject);
Object { photo_id="18", site_id="133", more...}
Why the change? The first result is json so why am I now getting this Object?