Reputation: 1406
What is considered the best practice for determining whether there are any rows bound?
Currently, I'm using the client-side OnDataBound event, and code similar to the following:
gridDataBound: function (event)
{
var rows = $('tbody tr:has(td)', this);
if (rows.length == 0 || (rows.length == 1 && rows[0].innerText == "No records to display'))
$('#GridSection').hide("slow");
}
There has got to be a better way!
Upvotes: 0
Views: 1683
Reputation: 13212
$('#grid-name').data('tGrid').data
is an array of all of the records.
So, you can get the number of records using:
$('#grid-name').data('tGrid').data.length;
Upvotes: 0
Reputation: 1406
Ah, a few minutes poking around and I think I have a solution that really feels better-
if ($("tbody tr:has(td).t-no-data", this).length != 0) {
$("#GridSection").hide("slow");
}
Upvotes: 0
Reputation: 30671
I can suggest a shorter version:
if ($(this).find(".t-no-data").length) {
$("#GridSection").hide("slow");
}
Upvotes: 1