Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to test if jqGrid has data or not?

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.

like image 238
pundit Avatar asked Mar 13 '12 14:03

pundit


People also ask

What is rowNum in jqGrid?

jqGrid exposes a property rowNum where you can set the number of rows to display for each page.

What is jqGrid example?

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.

What is jqGrid?

jqGrid is an Ajax-enabled JavaScript control that provides solutions for representing and manipulating tabular data on the web.


2 Answers

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.

like image 173
Justin Ethier Avatar answered Sep 21 '22 13:09

Justin Ethier


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.

like image 38
epascarello Avatar answered Sep 19 '22 13:09

epascarello