如何检测页面上的所有jqGrids是否都已加载? [英] How to detect if all jqGrids on a page have loaded?
问题描述
我正在使用jqGrid的ASP.NET WebForms版本,但是我确定应该将相同的事件用作标准网格.
我有一些页面上有多个网格,可能只是一个页面,也可能是多个页面.我有一个打印按钮,它将显示10,000条记录(以显示网格上的所有记录),将其调整大小以适合A4纸,然后按下window.print()
,然后返回到原始记录数,然后将网格重新调整为100%.
缺少的部分是知道什么时候触发window.print()
,因为我需要等待所有网格加载后才能这样做.
我尝试使用全局var allGridsLoaded = false;
,然后使用Load_Complete
事件和beforePageChange
来设置var,但是显然每个网格都重置了var,我不确定如何跟踪它们吗? /p>
在Load_Complete
中,我想我可以遍历每个网格,但是最清楚的方法是判断它们是否已加载?
我不确定我是否完全了解您的要求.尽管如此,在我看来您仍然需要
- 获取页面上的网格总数
- 为所有网格注册全局"
Load_Complete
- 在开始准备打印之前,将计数器设置为网格总数,开始重新加载网格,将全局"
Load_Complete
手柄内的计数器递减,如果计数器的值为0,则递减window.print()
.
因此,您真正需要的是上述列表中的第一件事.每个网格都将基于一个空的<table>
元素构建. jqGrid将"ui-jqgrid-btable"
类添加到所有表.所以你可以使用
$(".ui-jqgrid-btable")
获取页面上所有网格的jQuery包装. 有关其他信息,请参见答案. 我希望您能够以这种方式实现所有要求. I'm using the ASP.NET WebForms version of jqGrid, however I'm sure the same events should be available as the standard grid. I have some pages with multiple grids on them, it could be just one, or could be several. I have a print button which will display 10,000 records (to display all the records on the grid), resize it to fit onto an A4 sheet, fire The missing part is to know when to fire I've tried having a global In the I'm not sure that I full understand your requirements. Nevertheless it seems to me that you need So what you really need are two first things from the above list. Every grid will be build based on an empty to get jQuery wrapper to all grids on the page. See the answer for additional information. I hope you will be able to implement all your requirements in the way. 这篇关于如何检测页面上的所有jqGrids是否都已加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!$(".ui-jqgrid-btable").length
是网格数.要为所有网格注册通用的全局" Load_Complete
,可以使用jqGridLoadComplete
(或jqGridAfterLoadComplete
)事件(请参见 $(".ui-jqgrid-btable").bind("jqGridLoadComplete", function (e, data) {
// ...
});
window.print()
and then go back to the original record count, and resize the grid back to 100%.window.print()
as I need to wait for all the grids to be loaded before doing so.var allGridsLoaded = false;
and then use the Load_Complete
event and beforePageChange
to set the var, but obviously with each grid resetting the var I'm not sure how to track them all?Load_Complete
I'm thinking I could loop through each grid, but what's the cleanest way to tell if they've loaded?
Load_Complete
for all gridsLoad_Complete
handle and window.print()
if the counter will have the value 0.<table>
element. jqGrid adds "ui-jqgrid-btable"
class to all the tables. So you can use$(".ui-jqgrid-btable")
$(".ui-jqgrid-btable").length
is the number of grids. To register common "global" Load_Complete
for all grids you can use jqGridLoadComplete
(or jqGridAfterLoadComplete
) event (see the documentation):$(".ui-jqgrid-btable").bind("jqGridLoadComplete", function (e, data) {
// ...
});