Forum


23:40

26/01/2009

Hello,
I'm new to jqGrid and I'm having a little trouble.
I'm trying to constantly refresh a changing data source.
Here's my code:
setInterval(function (){
$.ajax({
url:'datatest.php',
cache: false,
success: function(testdata) {
$("#list1").jqGrid({
datastr: testdata,
datatype: "xmlstring",
colNames:['ColA','ColB', 'ColC', 'ColD'],
colModel:[
{name:'ColA', xmlmap:"COLA"},
{name:'ColB', xmlmap:"COLB"},
{name:'ColC', xmlmap:"COLC"},
{name:'ColD', xmlmap:"COLD"}
],
loadtext: false,
height:'100%',
xmlReader: {
root:"ROOT",
row:"ROWS",
page: 1,
total: 1,
records: "SESSION>rows",
repeatitems: false },
viewrecords: true,
sortorder: "asc",
caption:"Table Refresh Test"
});
}
})
}, 5000);
The table loads fine but will not refresh. I can see the jQuery ajax requests completing in the Firebug Console but the table contents remain stale. Moreover, I added .trigger("reloadGrid") without any success other than I saw the red "Loading..." box every 5 seconds but the data did not update.
Thanks in advance,
Chris
03:58

Moderators
30/10/2007

Hello
$(”#mygrid”).jqGrid({…..});
setInterval(function() { $(”#mygrid”).trigger(”reloadGrid”);},5000);
Also search this forum, there is a working exmple here.
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.
06:14

Moderators
30/10/2007

Hell,
As you see here you try to CREATE every time the grid after some interval - right?
This will not work after first time since there is a checking if the grid exists.
If the grid exists and you try to create it again nothing will be happen.
In you case I recommend you to check if the grid exist first
also in your ajax function
if(grid does not exists) {
//create the grid here
} else {
// triger to reload the grid
}
To check if the grid exists:
var mygrid = $("#migrid")[0];
if(mygrid.grid) // grid exists
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.
Most Users Ever Online: 715
Currently Online:
38 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