【发布时间】:2013-07-24 15:09:47
【问题描述】:
我正在尝试定期重新加载我的网格。我遇到了解决方案:
var grid = $("#list"),
intervalId = setInterval(
function() {
grid.trigger("reloadGrid",[{current:true}]);
},
300000); // 300 sec === 5 min
但我不确定将这段代码放在哪里。它会进入loadComplete 吗?我已经在使用了
jQuery("#list").trigger("reloadGrid", [{current:true}]);
喜欢这个
jQuery("#list").jqGrid({...
jQuery("#list").trigger("reloadGrid", [{current:true}]);
...});
我不知道在哪里访问
intervalId
请帮忙,。 谢谢
Oleg,这是我根据你的回答尝试过的:
// above this line is the grid code including nav grid
jQuery("#refresh_list").click(function(){
jQuery("#list").setGridParam({datatype: 'json'});
// jQuery("#list").trigger("reloadGrid");
setInterval(function() {
$('#list').trigger("reloadGrid", [{current:true}]);
alert("hello");}, 2000);
});
}); //This is the end of the document.ready function
我是否正确放置了 setinterval 函数?它应该在网格内部还是外部?它应该在 document.ready 内部还是外部? 令人惊讶的是,警报会如您所料弹出!但网格不会重新加载。我知道是因为我正在对数据库进行更改并且它们没有反映在网格中。当我单击刷新按钮时,它会按预期显示当前数据。我希望它定期重新加载,并始终拥有数据库中的最新数据。
顺便说一下,这些是我正在使用的网格选项
pager: "#pager", //Identifying the navigation bar
rowNum: 500, // how many rows to display on page 1
rowList: [500,1000, 2000, 3000,4000], //values for the dropdown which specifies how many rows to show
sortorder: "desc", //the order of sorting by default
viewrecords: true, // displays total number of rows
gridview: true, // the full grid body will be placed on the page as one operation
autoencode: true,
height:400, //height of the grid
ignoreCase:true,// case insensitive search
multiselect:true, // checkboxes before each row
multiboxonly: true,
loadonce:true, //for client side sorting, searching and pagination
caption:"This is me", // caption for the grid header
请帮忙
【问题讨论】:
标签: javascript jqgrid reload