How to get row count for jqGrid?

笑着哭i 提交于 2019-12-23 07:19:23

问题


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.


回答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.




回答2:


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



回答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>



回答4:


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

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



回答5:


<a href="javascript:void(0)" id="g9" onclick="alert(jQuery('#list').jqGrid('getGridParam','records'));">Get number of records in Grid</a>



回答6:


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);


来源:https://stackoverflow.com/questions/2587817/how-to-get-row-count-for-jqgrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!