Switch Json sources from in-memory to ajax
Switch Json sources from in-memory to ajax
richiebogchi
Posts: 1Questions: 0Answers: 0
Hi,
Is it possible to switch json sources from in-memory (javascript string in json format) to ajax source?
The datatable is initially set as follows (some code altered and omitted for simplicity)
[code]
var oTable = $(tableId).dataTable( {
..
"aaData" : [{"key1" : "value1" , "key2" : "value2" }],
"bServerSide" : false,
..
..
});
[/code]
After such initialization, I need to change the value of bServerSide to true and set the value for sAjaxSource.
I tried two approaches but it did not work. (The ajax call does not fire when i try to sort the tables) :
Approach 1
With the use of fnInitComplete
[code]
var oTable = $(tableId).dataTable( {
..
..
"fnInitComplete": function(oSettings, json) {
oSettings.sAjaxSource = "/ajax-request";
oSettings.bServerSide = true;
}
});
[/code]
Approach 2
Modifying bServerData and sAjaxSource after the datatables block
[code]
var oTable = $(tableId).dataTable( {
..
..
});
oTable.fnSettings().sAjaxSource = "/ajax-request";
oTable.fnSettings().bServerSide = true;
[/code]
Can someone help me with this problem?
Thanks!
Is it possible to switch json sources from in-memory (javascript string in json format) to ajax source?
The datatable is initially set as follows (some code altered and omitted for simplicity)
[code]
var oTable = $(tableId).dataTable( {
..
"aaData" : [{"key1" : "value1" , "key2" : "value2" }],
"bServerSide" : false,
..
..
});
[/code]
After such initialization, I need to change the value of bServerSide to true and set the value for sAjaxSource.
I tried two approaches but it did not work. (The ajax call does not fire when i try to sort the tables) :
Approach 1
With the use of fnInitComplete
[code]
var oTable = $(tableId).dataTable( {
..
..
"fnInitComplete": function(oSettings, json) {
oSettings.sAjaxSource = "/ajax-request";
oSettings.bServerSide = true;
}
});
[/code]
Approach 2
Modifying bServerData and sAjaxSource after the datatables block
[code]
var oTable = $(tableId).dataTable( {
..
..
});
oTable.fnSettings().sAjaxSource = "/ajax-request";
oTable.fnSettings().bServerSide = true;
[/code]
Can someone help me with this problem?
Thanks!
This discussion has been closed.
Replies
Sorry, but the code needed to be able to dynamically enable and disable features would probably add a lot of weight to the core library, which is why it is not available.
Allan