[英]Refresh button to call javascript function
In a page, I have a form and a JQGrid. 在页面中,我有一个表单和一个JQGrid。 The form is used to enter specific filters.
表单用于输入特定过滤器。 So the Javascript for that page contains a function which reloads the data in order to populate the JQGrid.
因此该页面的Javascript包含一个重新加载数据以填充JQGrid的函数。 The JQGrid has
loadonce: true
, so the refresh button doesn't do anything. JQGrid的
loadonce: true
,因此刷新按钮不执行任何操作。 I would need to make it call my existing function. 我需要让它调用我现有的函数。 Is it possible ?
可能吗 ?
If I understand you correctly then your problem exist because loadonce: true
option changes the original datatype
( "json"
or "xml"
) to "local"
. 如果我理解正确,那么你的问题就存在,因为
loadonce: true
选项会将原始datatype
( "json"
或"xml"
)更改为"local"
。 It allows to use local paging, sorting and filtering of data. 它允许使用本地分页,排序和数据过滤。 During the paging, filtering and sorting the grid will be reloaded, so local reloading do have sense.
在分页过程中,网格的过滤和排序将被重新加载,因此本地重新加载确实有意义。
If you need to reload the grid from the server you should first restore the original value of datatype
and then do reloading. 如果需要从服务器重新加载网格,则应首先恢复
datatype
的原始值,然后重新加载。
So if you can use beforeRefresh
callback of navGrid
to reset datatype
: 所以,如果你可以使用
beforeRefresh
的回调navGrid
重置datatype
:
$("#grid").jqGrid("navGrid", "#pager", {
beforeRefresh: function () {
$(this).jqGrid("setGridParam", {datatype: "json"});
}
});
If you use free jqGrid then you can use new fromServer: true
option of reloadGrid
and you can use new style of options and new reloadGridOptions
option of navGrid
. 如果您使用免费的jqGrid那么你可以使用新的
fromServer: true
的选项reloadGrid
,你可以使用的选项新风格和新reloadGridOptions
的选项navGrid
。 The code will be like 代码就像
$("#grid").jqGrid({
// standard jqGrid options
navOptions: {
// default options of navGrid
reloadGridOptions: {fromServer: true}
}
}).jqGrid("navGrid");
It will work with datatype:"json"
or datatype:"xml"
. 它将使用
datatype:"json"
或datatype:"xml"
。
A simple enough fix: 一个简单的修复:
loadonce: false
really, setting this to true will serve no other purpose that you have specified. 实际上,将此设置为true将不会用于您指定的其他目的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.