move column search filter to clone header? - Page 2

move column search filter to clone header?

2»

Answers

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    Take a look at the browser's console. You are getting this error which is stopping the Javascript script:

    jquery.dataTables.min.js:4 Uncaught TypeError: Cannot read properties of undefined (reading 'nTh')

    ITs due to this statement:

    api.columns([0, 3, 4, 5, 6, 7, 8, 9, 10])
    

    There are only 6 columns in the table. You care referencing column indexes that don't exist. It needs to be api.columns([0, 3, 4, 5]) for the test case. Updated test case:
    https://live.datatables.net/lohekifu/1/edit

    Also note that you don't need to create click events for the Datatables buttons. You can create a Custom buttons. I commented out the Expand All click event and added the code for the custom button so you can see how.

    Kevin

  • allanallan Posts: 63,683Questions: 1Answers: 10,498 Site admin

    If you look at the console in your browser, you'll see an error about the columns in the initComplete function. That is happening because you are using:

    api.columns([0, 3, 4, 5, 6, 7, 8, 9, 10])
    

    despite there being only 6 columns. Trying to access columns which don't exist will result in an error.

    Reducing it to the correct number of columns ( https://live.datatables.net/wokizoqu/1/edit ) allows it to run as expected.

    Allan

  • makimaxmakimax Posts: 45Questions: 2Answers: 0

    Thank you Allan, thank you so much Kevin for all the help you have given me.
    Do you know which version I should use, 1.13.10 or 2.0.0
    I see that in downloader it is the last one that is proposed. In 2.0.0 in my case the appearance changes a little with the same code. The Search button is no longer in the same place in my case but it is only cosmetic.

  • makimaxmakimax Posts: 45Questions: 2Answers: 0
    edited February 20

    On this, everything is OK, the last two columns are well hidden and the search button is well aligned with the custom buttons
    https://live.datatables.net/luwivima/1/edit
    The same but in datatables 2.0.0 : 4 columns are hidden instead of two and the search button shifts to a lower row (https://live.datatables.net/luwivima/1/edit)

Sign In or Register to comment.