如何获取 jqGrid 的行数?

发布于 2024-08-28 01:53:50 字数 194 浏览 3 评论 0原文

我想知道如何获取 jqGrid 的行数。我正在使用 rowNum: -1 因此它会显示所有行。我尝试使用:

parseInt($("#grid").getGridParam("records"), 10)

但它总是返回0

感谢您的帮助。

I would like to know how to get row count for jqGrid. I'm using rowNum: -1 so it displays all the rows. I tried using:

parseInt($("#grid").getGridParam("records"), 10)

But it always returns 0.

Thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

我是男神闪亮亮 2024-09-04 01:53:50

尝试:

$("#grid").getGridParam("reccount")

jqGrid 文档

重新计数整数):

只读属性。返回网格中的确切行数


另请注意,正如 Mike 所评论的,您需要使用 getGridParam 方法和 records 选项来检索所有行的计数如果您使用分页。

Try:

$("#grid").getGridParam("reccount")

from the jqGrid documentation:

reccount (integer):

Readonly property. Returns the exact number of rows in the grid


Note also that, as Mike commented, you need to use the getGridParam method with the records option to retrieve a count of all the rows if you are using pagination.

伴我心暖 2024-09-04 01:53:50
jQuery("#grid").jqGrid('getGridParam', 'records');
jQuery("#grid").jqGrid('getGridParam', 'records');
梦情居士 2024-09-04 01:53:50

我尝试重新计数,结果为零,但以下内容对我有用。

<div>Total subscriber count: <div id="count" style="display: inline;"></div></div>

<br />

<div>
    <table id="grid"></table>
</div>

<script type="text/javascript">

    $(document).ready(function () {
        $("#grid").jqGrid({
            //Other stuff removed for brevity
            gridComplete: function () {
                $('#count').html($('#grid').getGridParam('records'));
            }
        });
    });

</script>

I tried reccount and I got zero but the following worked for me.

<div>Total subscriber count: <div id="count" style="display: inline;"></div></div>

<br />

<div>
    <table id="grid"></table>
</div>

<script type="text/javascript">

    $(document).ready(function () {
        $("#grid").jqGrid({
            //Other stuff removed for brevity
            gridComplete: function () {
                $('#count').html($('#grid').getGridParam('records'));
            }
        });
    });

</script>
緦唸λ蓇 2024-09-04 01:53:50

这可能有点矫枉过正,不知道是否有更好的方法,但这对我有用:

$("#grid").getRowData().length

This might be overkill and don't know if there's a better way, but this works for me:

$("#grid").getRowData().length
猥琐帝 2024-09-04 01:53:50
<a href="javascript:void(0)" id="g9" onclick="alert(jQuery('#list').jqGrid('getGridParam','records'));">Get number of records in Grid</a>
<a href="javascript:void(0)" id="g9" onclick="alert(jQuery('#list').jqGrid('getGridParam','records'));">Get number of records in Grid</a>
一页 2024-09-04 01:53:50

我将网格数据获取到数组,然后使用数组长度函数来获取数组长度。它与jqgrid中的记录数相等。

//get the grid data to array      
var rows = $('#jqxgrid').jqxGrid('getrows');
//  get the length of the array on array.length using javascript funcation
alert('' + rows.length);

i get the grid data to array and then use the array length function to get the array length. It is equal for the number of record in the jqgrid.

//get the grid data to array      
var rows = $('#jqxgrid').jqxGrid('getrows');
//  get the length of the array on array.length using javascript funcation
alert('' + rows.length);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文