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.
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.
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.
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... –
Delphinedelphinia 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>
This might be overkill and don't know if there's a better way, but this works for me:
$("#grid").getRowData().length
<a href="javascript:void(0)" id="g9" onclick="alert(jQuery('#list').jqGrid('getGridParam','records'));">Get number of records in Grid</a>
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);
© 2022 - 2024 — McMap. All rights reserved.