I'm trying to have jqxbuttons enabled/disabled depending on whether my jqxgrid has data to display. The only way I could think of to check whether my jqxgrid is empty or not was to do something like:
// Retrieve row data from my grid
var rows = $('#myGrid').jqxGrid('getRows');
if (rows.length > 0)
console.log("Grid is not empty");
console.log("Grid is empty");
Your solution is potentially wrong, if you filter the grid.
getrows returns only the rows matching the filter.
Gets all rows. Returns an array of all rows loaded in the Grid. If the Grid is filtered, the returned value is an array of the filtered records.
You can use
Gets all rows loaded from the data source. The method returns an Array of all rows. The Grid's sorting, filtering, grouping and paging will not affect the result of this method. It will always return the rows collection loaded from the data source.
You could also use
$('#myGrid').jqxGrid('source').records.length. However, I think we cannot say that this is more easy.
Hope this helps!