Can't Change header dynamically

Can't Change header dynamically

habibillahhabibillah Posts: 4Questions: 0Answers: 0
edited November 2013 in Bug reports
I want to make a function on my own javascript file that will make data table both header and data can be changed dynamically as supplied on function parameters. However, jQuery DataTable seem catch header definition that cause datatable run fail.

I have made sample on JSFiddle at http://jsfiddle.net/a896Y/

can anyone help me to fix this problem?

Replies

  • habibillahhabibillah Posts: 4Questions: 0Answers: 0
    [quote] I have made sample on JSFiddle at http://jsfiddle.net/a896Y/ [/quote]

    Here sample update http://jsfiddle.net/a896Y/1/
  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    I'm afraid I don't agree that this is a bug. When the table is first loaded it has three columns. Then you destroy the table (reverting it back to its plain HTML state, with three columns) and then initialise it again, but now with only two columns defined and no where for it to get the data for the third column. Hence the warning that is given.

    If you want to remove one of the columns you need to use fnDestroy and then a bit of jQuery / DOM manipulation to actually modify the thead.

    Allan
  • habibillahhabibillah Posts: 4Questions: 0Answers: 0
    Hi Allan,

    It is not just to remove a column, but reinitialize columns and data. I have tried to use fnDestroy but same problem occur. see at http://jsfiddle.net/a896Y/4/ and http://jsfiddle.net/a896Y/3/
  • habibillahhabibillah Posts: 4Questions: 0Answers: 0
    I resolve this problem by create table tag trough javascript as

    [code]
    HTML
    -----


    Javascript
    -----

    var oTable = $('#datatable-sample').html('').children('table').dataTable({
    ...
    });
    [/code]

    Look at http://jsfiddle.net/a896Y/2/
This discussion has been closed.