Forum


12:23

13/11/2009

I have a jqgrid with datatype json that loads data from the server. We now want to add comet streaming to the grid and update the data from javascript. If we are using datatype local then we can update the grid from the comet streaming scripts by using the setRowData method. It looks like this method only works for datatype local. How can this be done when we use datatype json? (the json data from the server decides which rows to show, and we have 10.000+ rows - so switching entirely to datatype local is not an option).
I have tried something like this when updating the grid, but it does not work for me:
jQuery("#myGrid").jqGrid('setGridParam',{datatype:'local'});
jQuery("#myGrid").setRowData(itemName, rowData);
jQuery("#myGrid").jqGrid('setGridParam',{datatype:'json'});
Frode Oldervoll
13:05

Moderators
30/10/2007

Hello,
Try to use datatype as function. See examples.
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.
20:46

Moderators
30/10/2007

Hello,
Open the demo. select New in version 3.3 and the select Datatype as function
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.
18:06

13/11/2009

I actually got this to work with mixing json data and local data. The important thing that was missing from my last attempt it to use the id of the row when calling setRowData, not the item itself. Something like this works for me:
var ids = $('#mygrid').getDataIDs();
for (var i = 0; i < ids.length; i++) {
var item = $('#mygrid').getCell(ids[i], 0);
if (item === cometItem) {
$('#mygrid').jqGrid('setGridParam',{datatype:'local'});
$('#mygrid').setRowData(ids[i], rowData);
$('#mygrid').jqGrid('setGridParam',{datatype:'json'});
break;
}
}
Most Users Ever Online: 715
Currently Online:
189 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