Forum


14:43

10/11/2009

I see the note:
"If you use a jsonstring to obtain the data - after the data is retrieved the datatype option automatically is set to local - i.e. (currently) the paging will not work!"
I had been hoping, when doing our test setup with jqGrid, that I'd be able to "preload" the first, say, 10 records of a dataset to avoid the inital Ajax call. Then, using the pager, you'd go to page 2, and the Ajax call would occur.
Is this possible? Even based on that note, is there a way to override that functionality in some format? Direct hit to the object, anything?
- WB
16:53

11/11/2009

I was thinking through the same problem last week and i solved it like this. Start out with your datatype set to a function, that loads your initial data via "$table[0].addJSONData(initialResults)", and then make that same function overwrite the datatype property [itself].
var url = "/researchCatalog/Search/ProviderGridData/";
var gridData = getGridData(url, searchParams)
var colModel = gridData.colModel;
var initialResults = gridData.initialResults;
var datatype = function() {
//there's a little bit of trickery going on in this function
//so that we can create a jqGrid with initial results,
//and also hook into all of the auto AJAXy stuff built into the grid
//when initially creating the grid we use a function as the datatype,
//but in the function we reset the grids datatype to json
$table[0].addJSONData(initialResults)
//reset the datatype variable to json so it will make calls on its own
$table.setGridParam({ datatype: "json" });
}
$table.jqGrid({
url: url,
datatype: datatype,
colModel: colModel,
pagerpos: 'left',
pager: $("#" + pagerID),
pgbuttons: true,
gridComplete: function() {
RSCat.ContentManager.resizeGrid($table);
},
});
03:48

Moderators
30/10/2007

Hello,
IMHO There is a easy way and the solution is posted here many times
$("#mygrid").jqGrid({
url:'url_to_the_server_json_data',
datatype:'jsonstring'
datastr: actual_string_data_here,
...
})
// If your string data is relative big, make a settimeout to ensure that the new option will work
setTimeout(function() {$("#mygrid").jqGrid('setGridParam',{datatype:'json'}); },50);
// now you are ready to accept server requests
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.
00:04

16/10/2009

In Tony's solution, will setting the datatype back to "json" work via the gridComplete event like this:
$("#mygrid").jqGrid({
url:'url_to_the_server_json_data',
datatype:'jsonstring'
datastr: actual_string_data_here,
gridComplete: function(){$("#mygrid").jqGrid('setGridParam',{datatype:'json'}); }
…
});
Is there some reason I should use the setTimeout() instead?
Most Users Ever Online: 715
Currently Online:
192 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