Changing aaData and redraw

Changing aaData and redraw

TizTiz Posts: 4Questions: 0Answers: 0
edited September 2010 in General
Hi, i use dataTable with JSON input and i'd like to refresh the table by changing the aaData and refresh the table.

So that's what i did :

[code]oTable = $(container).dataTable();
oTable.fnSettings().aaData = table.aaData; // where table.aaData contains the new aaData
oTable.fnDraw(); [/code]

The problem is that the table isn't really redrawed.. I can see in firebug that the settings has been changed in the DOM, but the table doesn't want to change...

Can you help me please ?

PS :
Have you got a function to check that a selector is or not a dataTable ? so because i'm using it with json i checked if it was empty like that
[code]if($('tr', container).length != 0)[/code] but is there a better way ?

Thank you very much

Replies

  • TizTiz Posts: 4Questions: 0Answers: 0
    And i use dataTable 1.7.1 with jquery 1.4.2 under firefox 3.6.8 ^^
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Hi Tiz,

    There is no "fnSettings().aaData" parameter - so this wouldn't work. What you would need to do is use fnClearTable() followed by fnAddData() - http://datatables.net/api - which would give you this effect and uses the public API methods.

    Allan
  • polskikrolpolskikrol Posts: 10Questions: 0Answers: 0
    Do any public API methods exist for modifying columns? For instance, if I want to add another column and then dynamically reload data.

    An instance this would be useful is when reading a database and not wanting to display all data types, but allowing the user to pick and add more data columns.

    Ideally, would be nice to do this without having to reinstantiate the table and reapply all settings.
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    At the moment I'm afraid not - no. It is not possible to dynamically add and remove columns from a table at this time (well - it is possible, but there is no implementation for it!). It sounds like ColVis ( http://datatables.net/extras/colvis/ ) might be something which is of use to you? Or possibly just wrap up fnSetColumnVis with your own calls.

    Allan
This discussion has been closed.