I'm trying to enable and disable custom buttons on a jqgrid, but would enable that button only if the grid is empty and then disable when its not.
Is there a way to test of the grid has data or not?
Thanks.
jqGrid exposes a property rowNum where you can set the number of rows to display for each page.
Free jqGrid is a JavaScript plugin that displays table-based data in a lot of different configurations. The data can be loaded from JavaScript array or be loaded from the server (in JSON or XML format). It supports client-side paging, sorting and filtering on server-side.
jqGrid is an Ajax-enabled JavaScript control that provides solutions for representing and manipulating tabular data on the web.
You can test to see how many records are in the grid. If there are no rows then the grid is empty:
jQuery('#grid').jqGrid('getGridParam', 'reccount');
See the documentation for reccount:
Readonly property. Determines the exactly number of rows in the grid.
Also, since the default value is 0
you need to make sure you call this function after data has loaded, such as in the loadComplete
event.
From the docs:
reccount integer Readonly property.
Determines the exactly number of rows in the grid. Do not mix this with records parameter. Instead that in most cases they are equal there is a case where this is not true. By example you define rowNum parameter 15, but you return from server records parameter = 20, then the records parameter will be 20, the reccount parameter will be 15, and in the grid you will have 15 records.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With