change "columns" in FixedColumns dataTable

change "columns" in FixedColumns dataTable

guoqiguoqi Posts: 5Questions: 2Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin

    Going to need a little more to go on than an empty post! Could you fill in the template text please, with a link to your test case so we can offer some help and also describe the issue.

    Allan

  • guoqiguoqi Posts: 5Questions: 2Answers: 0

    I init a FixedColumns table,use options of “ajax” to call data,and options of "columns" to build column's title and render based on a time range selector.
    Just entered the page,table is ok :

    <table id="dt-table"></table>
    $(function() { initTable()});

    then, I change time range selector , for example,change time range from 3.1-3.7 to 4.2-4.20.now click a button ,I want to change value of options "columns", Rerequest the protocol and draw the table with 4.2-4.20:

    $('#searchBt').on('click', function () { initTable(); })
    But it can't live up to that expectation.thead is disappeared,and console report an error:

    It's even stranger that I click the button second time,table is right.the third time is Wrong.For the fourth time is right.So on and on

    how do I change the "columns" options correctly in FixedColumns dataTable~~~~

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    edited July 2020

    Allan posted this:

    Could you fill in the template text please, with a link to your test case so we can offer some help and also describe the issue.

    Respecting the forum rules is the best way to get help.

  • guoqiguoqi Posts: 5Questions: 2Answers: 0

    The LAN has no external links...

  • guoqiguoqi Posts: 5Questions: 2Answers: 0

    Does it have a way to change option item to update? like setOption()、update()

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    Most Datatables options, including columns, don't have a way to change the config dynamically. The destroy() API or destroy option is used to change the config options. This requires reinitializing the Datatable.

    Kevin

This discussion has been closed.