如何获取jqGrid中显示的行数? [英] How can I get the number of rows displayed in a jqGrid?

查看:416
本文介绍了如何获取jqGrid中显示的行数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这些信息在那里,而我的Google-fu却使我失望了,但是我似乎找不到答案.如何获取jqGrid中当前正在显示的行数?

Maybe this information is out there and my Google-fu is failing me, however I can't seem to find the answer. How can I get the number of rows being currently displayed in a jqGrid?

我在此主题上找到的每个问题和答案都告诉您如何获取(显示或不显示)总行数或已加载的行数.通过外部服务.相反,我试图获取jqGrid当前页面中显示的行数.我的jqGrid属性之一是rowList:[10,20,30],但是我不确定如何访问自己选择的那个属性.

Every question and answer I've found on this topic tells you how to get either the total number of rows (displayed or not) or the number of rows loaded by an external service. Instead, I'm trying to get how many rows are being displayed in the current page of the jqGrid. One of my jqGrid attributes is rowList:[10,20,30], but I'm not sure how to access which one is selected myself.

我想要的是jqGrid的每个页面上当前显示多少行.到目前为止,我发现的最接近的东西是此问题与解答,但这显示了有多少<tr>个,并不是我真正需要的.

All I want is how many rows are being currently dislpayed on each page of the jqGrid. The closest thing I've found so far has been this Q&A, but this displayed how many <tr>s there are and wasn't really what I needed.

推荐答案

$('.ui-pg-selbox').val()

在最新的jqGrid(4.4.1)上进行了测试

Tested on the latest jqGrid (4.4.1)

当然,如果每页的jqGrid多于一个,则可以使用包装器以确保它是您要寻找的包装器.

Of course, if you have more than jqGrid per page, you can use an wrapper to ensure that it is the one you're looking for.

$('#myjqGridWrapper .ui-pg-selbox').val()

不确定这是否是最好的方法,但是可以完成工作.

Not sure whether it's the best way, but it gets the job done.

该空间表示后代选择器,即它查找包含类ui-pg-selbox的元素,这些元素是包装器#myjqGridWrapper的后代.那将需要在表周围使用div或其他包装材料.

The space means a descendant selector, that is it looks for elements containing the class ui-pg-selbox which are descendant of an wrapper #myjqGridWrapper. That would require having a div or some other wrapper around your table.

更新:另外,如果您具有table ID或引用,则可以使用更坚固的方法来查询其jqGrid实例的.ui-pg-selbox:

UPDATE: Also, if you have the table ID or a reference, you can use a more sturdy way of querying its jqGrid instance's .ui-pg-selbox:

$('#jqgridTableId').closest('.ui-jqgrid').find('.ui-pg-selbox').val()

这篇关于如何获取jqGrid中显示的行数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆