fnReloadAjax plugin function appears to bypasses fnInfoCallback

fnReloadAjax plugin function appears to bypasses fnInfoCallback

rgvcorleyrgvcorley Posts: 29Questions: 0Answers: 0
edited June 2012 in General
I am using fnInfoCallback to add 'x rows selected' to the info. this is all working fine except for tables which are using an ajax source. The table renders correctly at initialization, calling my callback function, however when I call fnReloadAjax it appears to bypass the fnInfoCallback.

I've setup a test case here, although it's not really a true case because I couldn't get the ajax source to work. There should be 2 alerts, one for the initialization and one after calling fnReloadAjax.

http://live.datatables.net/uvadup/6/edit#javascript,html,live

any help much appreciated :)

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Just made a few updates: http://live.datatables.net/uvadup/8/edit . It seems to work okay to me :-) (have a look at the console in your browser - JSBin appears to override 'alert').

    Allan
  • rgvcorleyrgvcorley Posts: 29Questions: 0Answers: 0
    edited June 2012
    Yeah I've discovered what's happening - for some reason my attempts to get the TableTools object (which I use to get the # of selected rows for the info) fail after the table is reloaded using fnReloadAjax.

    The way I am saving and getting the TableTools object is saving it using $.data() and then retrieving like this:-

    [code]
    var oTableTools = $('#' + id).data('oTableTools');
    [/code]

    Where id is the css id of the table. This works well except after calling fnReloadAjax(); - the TableTools object is undefined, as if the DOM for the actual element is reloaded, wiping the data that jquery has attached to it with $.data()?

    I have tried using TableTools.fnGetInstance(id); instead but this returns null and fnGetMasters returns an empty object. This is on first initialization, it doesn't even get as far as fnReloadAjax.

    I imagine there is probably some issue with the method I am using to initialize DT, so it's probably not possible to say what the issue is without seeing some more code, it's clearly not a problem with DT or TT. But any pointers you might have would be very much appreciated.
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    That's odd - TableTools should be getting the TABLE node rather than actually really caring about what is inside the table (selected rows are an exception...)

    I'm afraid I'd be reduced to adding code to debug that one, as I don't know what would be causing the issue.

    I think longer term I need a better way of getting the plug-in instances from the DataTables instance. I'll look into that!

    Regards,
    Allan
  • rgvcorleyrgvcorley Posts: 29Questions: 0Answers: 0
    edited June 2012
    Yeah it would be really neat to be able to something like oTable.fnGetPluginInstance('TableTools'); or something, because I've always got a reference to the main DT object.

    Anyway, I'll have another look at it tomorrow and see if I can work out what's going on. If not I'll drop you an email - not much point in clogging up the forum with something that is almost certainly going to be specific to my exact case!

    thanks!

    Rob.
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Exactly something like that - the one thing that I haven't fully decided how to do yet is deal with multiple instances - I want to allow multiple TableTools for example, thus allowing different button sets on a table to be used.

    Again with my long term plans for DataTables :-)

    Allan
This discussion has been closed.