How to refer to datatable after creation ?

How to refer to datatable after creation ?

fvantfvant Posts: 6Questions: 0Answers: 0
edited February 2010 in General
I have a set of dynamically created jquery-ui tabs and each has a datatable that i'd like to load when a tab is selected/clicked.

The datatables are created like $('.account').datatable(....) because they share the same style. They do have a unique id. I have setup the ui click event and that works ok.

How can i refer to an individual table later to call fnReloadAjax( url ) on it ?

Replies

  • netmannetman Posts: 15Questions: 0Answers: 0
    I don't have an answer, but i do have a question.Is it possible to post a demo url? I'm also stacked on the same "challenge", so i'd like to see what you've done so far.

    Thank you
    Steve
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi folks,

    This came up just a few days ago actually, so nice and easy for me to link to: http://datatables.net/forums/comments.php?DiscussionID=1207#Item_4 :-)

    Hope that helps,
    Allan
  • fvantfvant Posts: 6Questions: 0Answers: 0
    edited February 2010
    That helped indeed.

    I added an attribute to the on each of the Tabs and use this to find the tab i need.
    [code]
    $('#'+ui.panel.id ).attr("tab")
    [/code]

    in the function i then set the the right tablenumber as shown in the other thread.
    [code]

    $.fn.dataTableExt.iApiIndex = tab;
    oTable.fnReloadAjax('/ajax.php?data=acctlist&id='+id);
    [/code]

    But the ReloadAjax now complains about oSettings not set, when i add it the source is null, what's up ?
  • fvantfvant Posts: 6Questions: 0Answers: 0
    edited February 2010
    What is wrong with this snippet ?

    It uses the oset as the datasource insteadof url. When i leave oset out, the correct url is used but into the wrong table.

    [code]
    $.fn.dataTableExt.iApiIndex = tab;
    var oset= oTable.fnSettings();
    url = '/ajax.php?data=acctlist&id='+id;
    oTable.fnReloadAjax( oset, url, '' );
    [/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You don't need to put the settings object in yourself - DataTables will do that automatically. The correct call is fnReloadAjax( url, function(){/* if you want a callback */} );

    However, I'm not seeing why this would fail for you - which you point out it does. It's possible that there is a bug here - but I don't see it on a scan through the code... I think I'll need to set up a test example, but can't to that at this moment unfortunately. I'll see if I can get back to you soon about this.

    Allan
  • fvantfvant Posts: 6Questions: 0Answers: 0
    I can send you the page i am working on, would that help ?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes please - that would be useful indeed. http://datatables.net/contact if you don't want it public on the forum :-)

    Allan
  • fvantfvant Posts: 6Questions: 0Answers: 0
    Did the example that i submitted help to find the problem ?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Sorry about that - e-mail sent :-). Hopefully we'll get an answer and be able to post it here.

    Allan
This discussion has been closed.