Reading properties
Reading properties
Hi again,
My datatables are running in a JQuery UI tab, and I want to load the table when the tab is selected.
My datatable is initialised without the sAjaxSource being set, then when the tab is selected, I'm using fnReloadAjax to load the data. That part works fine.
What i'd like to do is determine if some data has already been loaded, i.e. only load data the first time the tab is selected.
Can you explain how I can determine if data is loaded, either by reading the value of the sAjaxSource value or another way?
[code]
$("#maintabs").tabs(
{
select: function(event, ui)
{
if (ui.panel.id=="diary")
{
masterDiaryTable.fnClearTable();
masterDiaryTable.fnReloadAjax("json_masterdiary.asp");
};
}
});
[/code]
My reason for doing this is to keep load time to a minimum as I have quite a few datatables loading at once.
My datatables are running in a JQuery UI tab, and I want to load the table when the tab is selected.
My datatable is initialised without the sAjaxSource being set, then when the tab is selected, I'm using fnReloadAjax to load the data. That part works fine.
What i'd like to do is determine if some data has already been loaded, i.e. only load data the first time the tab is selected.
Can you explain how I can determine if data is loaded, either by reading the value of the sAjaxSource value or another way?
[code]
$("#maintabs").tabs(
{
select: function(event, ui)
{
if (ui.panel.id=="diary")
{
masterDiaryTable.fnClearTable();
masterDiaryTable.fnReloadAjax("json_masterdiary.asp");
};
}
});
[/code]
My reason for doing this is to keep load time to a minimum as I have quite a few datatables loading at once.
This discussion has been closed.
Replies
I don't have an ajax source so I don't know if this will work, but you could do a check for if masterDiaryTable.fnGetNodes(0) returns anything... if it does you can probably assume the table is populated, otherwise it isn't. Are the tables empty when first initialised?
Another possibility is to use the fnSettings api function. I believe masterDiaryTable.fnSettings().aoData should return an array of all rows currently in dataTables. So fnSettings().aoData.length == 0 might be a good way to check.
I hope this helps.