bRetrieve to get access to already initialized dataTable to perform refresh not working as expected?
bRetrieve to get access to already initialized dataTable to perform refresh not working as expected?
Hey,
I have some code in my document onLoad that sets up a dataTable that reads its data from an AJAX source.
The dataTable has an associated "edit" pane with save buttons -- whenever a user clicks an element in the data table, an "edit" form loads in that pane, and they may save their data.
I'd like to trigger a refresh of the dataTable's data from the AJAX source whenever a user saves an element in the edit form.
This is where I'm tripping up...
I don't have access to the original dataTable reference so I'm trying to use bRetrieve on the same jQuery selector to get it, but it doesn't seem to work:
[code]
group_right.delegate('form a.module_save_button', 'click', function() {
if(!$(this).attr('disabled')){
console.log(group_table.find('table'));
var dTable = group_table.find('table').dataTable({'bRetrieve': true});
console.log(dTable);
dTable.fnDraw(false);
console.log("reloaded...");
}
});
[/code]
(I saw in another thread that fnDraw would trigger a refresh -- but it doesn't seem to do anything)
The console.log(dTable) line does log out an HTML element.
Any thoughts?
I have some code in my document onLoad that sets up a dataTable that reads its data from an AJAX source.
The dataTable has an associated "edit" pane with save buttons -- whenever a user clicks an element in the data table, an "edit" form loads in that pane, and they may save their data.
I'd like to trigger a refresh of the dataTable's data from the AJAX source whenever a user saves an element in the edit form.
This is where I'm tripping up...
I don't have access to the original dataTable reference so I'm trying to use bRetrieve on the same jQuery selector to get it, but it doesn't seem to work:
[code]
group_right.delegate('form a.module_save_button', 'click', function() {
if(!$(this).attr('disabled')){
console.log(group_table.find('table'));
var dTable = group_table.find('table').dataTable({'bRetrieve': true});
console.log(dTable);
dTable.fnDraw(false);
console.log("reloaded...");
}
});
[/code]
(I saw in another thread that fnDraw would trigger a refresh -- but it doesn't seem to do anything)
The console.log(dTable) line does log out an HTML element.
Any thoughts?
This discussion has been closed.
Replies
When I call fnReloadAjax() with no parameters, it tries reloading the list from elsewhere(that is, not what I set as sAjaxSource).
When I specify a URL in fnReloadAjax('...') it does not include the normal GET parameters that it makes when the page initially loads the AJAX data(sEcho, iDisplayStart, etc...)
[code]
group_right.delegate('form a.module_save_button', 'click', function() {
// this doesn't work -- it's supposed to refresh the dataTable when
// a user saves
if(!$(this).attr('disabled')){
var dTable = group_table.find('div.dataTables_scrollBody table').dataTable({'bRetrieve': true});
dTable.fnReloadAjax();
}
});
[/code]
However, the parameters that are passed for server-side processing(as I had the bServerSide flag set) are no longer passed in the AJAX request!
So I disabled server-side processing, but now my initial pageload isn't actually creating any rows in the dataTable. The AJAX request is made, data is returned(the SAME data as when I was using server-side processing), and no rows get created in the table. There are no Javascript errors either, though -- I'm lost.
So I guess the question now is:
1) How can you enable server-side processing in the fnReloadAjax plugin?
or
2) Why is my dataTable not rendering rows with valid JSON data when bServerSide = false, yet work with the same JSON data when bServerSide = true?