如何让jqGrid重新加载到服务器? [英] How to get jqGrid reload to go to server?
问题描述
我们在loadonce
设置为true的网格上使用jqGrid导航器重新加载按钮.
We use the jqGrid navigator reload button on a grid with loadonce
set to true.
重新加载按钮当前不返回服务器以获取数据-我们如何才能使重新加载进入服务器以获取最新数据?
The reload button currently does NOT go back to the server to get the data - how can we get the reload to go to the server to get the latest data?
我相信我们可以使用 beforeRefresh
回调将网格data
设置为json
而不是local
,但是我不清楚如何配置beforeRefresh
方法-我不太了解文档.
I believe we can use the beforeRefresh
callback to set the grid data
to json
instead of local
but I'm not clear how to even configure the beforeRefresh
method - I don't really understand the docs.
推荐答案
您不是唯一遇到问题的人.我之前回答了相同的问题.要从服务器重新加载网格内容,应将datatype
参数重置为原始值"json"或"xml",然后刷新网格.例如
You are not the only person which has the problem. I answerd to the same question before. To reload the grid content from the server you should reset the datatype
parameter to original value "json" or "xml" and then refresh the grid. For example
jQuery("#list").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
UPDATED: To call the line inside of beforeRefresh event handler you can do following
jQuery("#list").jqGrid('navGrid','#pager',
{ edit:false,view:false,add:false,del:false,search:false,
beforeRefresh: function(){
alert('In beforeRefresh');
grid.jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
}
});
我从一个古老的问题中修改了一个例子. 在这里,如果您点击刷新按钮,则可以实时查看代码工作.
I modified an example from am old question. Here if you click on the refresh button you can see live how the code work.
更新2 :免费jqGrid 支持一些新选项. reloadGrid
事件支持fromServer: true
参数,该参数可用于强制从服务器重新加载数据,而navGrid
支持reloadGridOptions
选项,该选项可用于指定单击刷新按钮时使用的reloadGrid
选项.所以上面的代码可能是
UPDATED 2: Free jqGrid supports some new options. reloadGrid
event supports fromServer: true
parameter which can be used to force reloading of data from the server and navGrid
supports reloadGridOptions
option which can be used to specify the options of reloadGrid
used on click on Refresh button. So the above code could be
$("#list").jqGrid("navGrid", {
edit: false,
add: false,
del: false,
search: false,
reloadGridOptions: { fromServer: true }
});
通过一种方式,可以使用jqGrid的navOptions
选项指定navGrid
的默认选项(请参阅Wiki文章).它允许编写类似
By the way one can use navOptions
option of jqGrid to specify default options of navGrid
(see the wiki article). It allows to write the code something like
$("#link").jqGrid({
// all typical jqGrid parameters
datatype: "json", // or "xml"
loadonce: true,
pager: true, // no empty div for page is required
navOptions: {
edit: false,
add: false,
del: false,
search: false,
reloadGridOptions: { fromServer: true }
}
}).jqGrid("navGrid");
这篇关于如何让jqGrid重新加载到服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!