How to get row count for jqGrid?

68,224

Solution 1

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.

Solution 2

jQuery("#grid").jqGrid('getGridParam', 'records');

Solution 3

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>

Solution 4

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

$("#grid").getRowData().length
Share:
68,224
Admin
Author by

Admin

Updated on May 12, 2020

Comments

  • Admin
    Admin almost 4 years

    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.

  • Mike Gledhill
    Mike Gledhill over 9 years
    Note that if you have paging turned on in your jqGrid, this function will just return the number of rows shown on this page. To get the full row count, use the 'getGridParam' function, shown in one of the other answers.
  • Justin Ethier
    Justin Ethier over 9 years
    @MikeGledhill - Thanks, I updated this answer to include records since none of the other answers explain why that works. Note the op was not using pagination, but a lot of people reading this could be...