I'm using YUI2 DataSource to load JSON data and after that DataTable to display it.
Before initializing DataTable, I would like to check if there are any results in the data source and initialize the table only if there's something to show. Is there a way I can do that?
If I remember correctly YUI DataTables can be automatically and transparently bound to a DataSource. But that would not behave as you want.
You could do what you need by setting up your DataSource first, and then initializing the DataTable within the asynchronous javascript function called when the DataSource succeeds in getting data (usually a closure passed to the DataSource). That should work.
Alternatively, and maybe even better if you are using dynamic polling at regular interval, you could setup div containing the DataTable visible or not depending if there anything to show (with default to invisible so the DataTable would not be visible before data has been received).