如何在对其中任何一个进行更改后重新加载页面上的所有 jqgrids
how to reload all jqgrids on the page after changes made in any of them
我在一个页面上有几个 jqgrids..现在我想在更新其中任何一个的记录后重新加载这两个 jqgrids。
这是我的 body..
<div style="position: relative; top: 40px; width:50%">
<table id="list"><tr><td></td></tr></table>
<div id="pager"></div>
</div>
<div style="position: relative; top: -250px; left:50%;">
<table id="list1"><tr><td></td></tr></table>
<div id="pager1"></div>
</div>
这里是第一个 jqgrid 提交功能后的脚本...
afterSubmit: 函数(响应,postdata)
{
if (response.responseText === "OK")
{
alert("Update is succefully");
alert(this);
$(this).jqGrid("setGridParam", {datatype: 'json'});
return [true, "", ""];
alert("#list1");
$("#list1").jqGrid("setGridParam", {datatype: 'json'});
return [true, "", ""];
// $(this).trigger('reloadGrid');
}
else {
alert("Update failed");
return [true, "", ""];
}
}
现在使用此代码,我的第一个 jqgrid 确实在更新数据后重新加载并在该 jqgrid 中显示更新后的数据,但是第二个具有 ID #list1 的 jqgrid 没有得到 reloaded/refreshed。我如何实现这个?
不清楚您指的是哪个变化。如果你使用 free jqGrid fork, then the recommended way to reload the grid from the server, if it has loadonce: true
option, would be to use .trigger("reloadGrid", {fromServer: true})
or $("#list").trigger("reloadGrid", [{fromServer: true, current: true, page: 1}]);
(see the answer or this one)。因此,您可以执行以下操作:
$(".ui-jqgrid-btable").trigger("reloadGrid", {fromServer: true});
如果您需要在 afterSubmit
之类的回调中触发重新加载网格,那么我建议您将上述代码包装在 setTimeout
中以允许完成 [=15] 的处理=] 重新加载网格之前:
afterSubmit: function () {
setTimeout(function () {
$(".ui-jqgrid-btable").trigger("reloadGrid", {fromServer: true});
}, 50);
return [true, "", ""];
}
我在一个页面上有几个 jqgrids..现在我想在更新其中任何一个的记录后重新加载这两个 jqgrids。
这是我的 body..
<div style="position: relative; top: 40px; width:50%">
<table id="list"><tr><td></td></tr></table>
<div id="pager"></div>
</div>
<div style="position: relative; top: -250px; left:50%;">
<table id="list1"><tr><td></td></tr></table>
<div id="pager1"></div>
</div>
这里是第一个 jqgrid 提交功能后的脚本...
afterSubmit: 函数(响应,postdata)
{
if (response.responseText === "OK")
{
alert("Update is succefully");
alert(this);
$(this).jqGrid("setGridParam", {datatype: 'json'});
return [true, "", ""];
alert("#list1");
$("#list1").jqGrid("setGridParam", {datatype: 'json'});
return [true, "", ""];
// $(this).trigger('reloadGrid');
}
else {
alert("Update failed");
return [true, "", ""];
}
}
现在使用此代码,我的第一个 jqgrid 确实在更新数据后重新加载并在该 jqgrid 中显示更新后的数据,但是第二个具有 ID #list1 的 jqgrid 没有得到 reloaded/refreshed。我如何实现这个?
不清楚您指的是哪个变化。如果你使用 free jqGrid fork, then the recommended way to reload the grid from the server, if it has loadonce: true
option, would be to use .trigger("reloadGrid", {fromServer: true})
or $("#list").trigger("reloadGrid", [{fromServer: true, current: true, page: 1}]);
(see the answer or this one)。因此,您可以执行以下操作:
$(".ui-jqgrid-btable").trigger("reloadGrid", {fromServer: true});
如果您需要在 afterSubmit
之类的回调中触发重新加载网格,那么我建议您将上述代码包装在 setTimeout
中以允许完成 [=15] 的处理=] 重新加载网格之前:
afterSubmit: function () {
setTimeout(function () {
$(".ui-jqgrid-btable").trigger("reloadGrid", {fromServer: true});
}, 50);
return [true, "", ""];
}