Can't get dynamic reloading to work...
Can't get dynamic reloading to work...
michael.griffith
Posts: 7Questions: 0Answers: 0
Following the example for reloading the dataset dynamically, I have a button that a user clicks to display the DataTable -- which pulls data from the server based on what the user clicked on. The server side code is never being invoked, so I am not sure what I am doing wrong. Using DataTables 1.6.2 with Struts 2.
[code]
partsData=$('#parts_table').dataTable( {
"bProcessing" : true,
"bServerSide": true,
"sAjaxSource": "./partlist-data.do",
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
aoData.push( { "name": "engineId", "value": "1" } );
$.getJSON( sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
});
}
});
[/code]
In the test above, the struts action is not invoked each time I display/hide the table. I have hard coded the value I want to pass but it would be pulled from a hidden form field value using $("#engineId").val();
I tried calling the redraw function before the div that the table is in is shown, but I get an oSettings = null error when doing so...
[code]
partsData.fnClearTable(0);
partsData.fnDraw();
[/code]
This produces oSettings is null
Concept seems simple... what could I be doing wrong?
Any/all replies are appreciated.
[code]
partsData=$('#parts_table').dataTable( {
"bProcessing" : true,
"bServerSide": true,
"sAjaxSource": "./partlist-data.do",
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
aoData.push( { "name": "engineId", "value": "1" } );
$.getJSON( sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
});
}
});
[/code]
In the test above, the struts action is not invoked each time I display/hide the table. I have hard coded the value I want to pass but it would be pulled from a hidden form field value using $("#engineId").val();
I tried calling the redraw function before the div that the table is in is shown, but I get an oSettings = null error when doing so...
[code]
partsData.fnClearTable(0);
partsData.fnDraw();
[/code]
This produces oSettings is null
Concept seems simple... what could I be doing wrong?
Any/all replies are appreciated.
This discussion has been closed.
Replies
Allan
If not - then an alert() just before the $().dataTable() call?
Allan