How to apply data table plugin to dynamically added table using jquery ?

How to apply data table plugin to dynamically added table using jquery ?

san0820san0820 Posts: 9Questions: 1Answers: 0
edited February 2014 in DataTables 1.8
Hi,
I am trying to add data table plugin to dynamically added table($(body).append(""));

unable to add this plugin to that table actually
and heard that data table plugin will not be applied to the content which are not prepared in DOM is it right?

Can anybody please help me on this.

Replies

  • allanallan Posts: 61,443Questions: 1Answers: 10,053 Site admin
    DataTables will work on any HTML table element, regardless of when it is put ingot he DOM.

    This example shows it running on a table that is injected into the DOM: http://datatables.net/release-datatables/examples/data_sources/js_array.html

    Allan
  • san0820san0820 Posts: 9Questions: 1Answers: 0
    Thank u very much Allan,

    One more help I need is , can u please give me an example rendering data from ajax source by poting some data , it will be very helpful to me.
  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394
    http://www.datatables.net/release-datatables/examples/data_sources/ajax.html
  • san0820san0820 Posts: 9Questions: 1Answers: 0
    Hi Tangerine,

    Thank u very much , Your ref helped me

    I do have another problem actually that is when I am calling a similar function which is an action for an event on click i am getting an error like "DataTables warning (table id ='studentsTable') cannot reinitialise Data table. To retrive the Data Tables object for this table, pass no arguments or see the docs for bRetrieve and b Destroy"
    even after doing this also css not applying that particular selector table, please help me in that


    Thanks,
    San
  • allanallan Posts: 61,443Questions: 1Answers: 10,053 Site admin
    See this tech note for details on that error: http://next.datatables.net/manual/tech-notes/3

    Also, in future, please link to tests cases when requesting help so we can look at the code and be able to offer the help you are asking for.

    Allan
This discussion has been closed.