Can't get dynamic reloading to work...

Can't get dynamic reloading to work...

michael.griffithmichael.griffith Posts: 7Questions: 0Answers: 0
edited September 2010 in General
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.

Replies

  • michael.griffithmichael.griffith Posts: 7Questions: 0Answers: 0
    Bump? Can no one tell me what is wrong with the example I posted above?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I don't really see anything wrong with the code you've posted (although you don't need to call fnClearTable - fnDraw basically done that anyway with server-side processing). Are you sure the code is being invoked? Any JS errors in the console?

    Allan
  • michael.griffithmichael.griffith Posts: 7Questions: 0Answers: 0
    Thanks for your reply Allan. No JS errors are reported in FireBug. The call to fnClearTable was a desperate attempt to make it work, so I'll remove it. The server side code is never being invoked -- which is what my question/problem pertains to...
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    So if you put in an alert() just before the call to $.getJSON - does that occur?

    If not - then an alert() just before the $().dataTable() call?

    Allan
This discussion has been closed.