Removing column from table after initialisation

Removing column from table after initialisation

trongarttrongart Posts: 222Questions: 51Answers: 0

I am looking for a way to remove a column from the table, searchFilter, searchBuilder, and colVis after initialisation as in this test case: live.datatables.net/bulutulo/1/edit

It it possible to remove the Office column or alternatively to hide it from all components?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    Most initialization options can't be changed via the API. Using destroy() or destroy and reinitializing with the new options is the way to change them.

    Kevin

  • trongarttrongart Posts: 222Questions: 51Answers: 0
    edited August 2022

    @kthorngren Thank you for looking into this. Since this can't be changed via the API, I'm aiming to hide the Office column in this test case in the table, searchFilter, searchBuilder and colVis:
    live.datatables.net/kedudaji/1/edit

    I managed to hide the column in the table, but what would be the correct way to also hide the Office column in the searchBuilder and colVis after the initial var table = $('#example').DataTable code?

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    edited August 2022 Answer ✓

    Search Builder uses searchBuilder.columns and colvis uses columns to define which columns are included for use with the extensions. These are Datatables initialization parameters and can only be changed, as I described above, by destroying and reinitializing with the new options. There are no API's to change these.

    One option could be to apply a hidden attribute to the Search Builder and colvis columns you don't want displayed. You can inspect these elements to find a suitable selector to hide them.

    Kevin

Sign In or Register to comment.