Show DataTable columns depending on select option header
Show DataTable columns depending on select option header
HELLO EVERYONE. I WAS WONDERING IF ANYONE COULD HELP ME WITH SOMETHING.
I HAVE A MULTISELECT OPTION PLUGIN, IN WHICH ARE THE HEADERS OF THE TABLE. WHAT I WANT TO DO IS WHENEVER I CLICK A SELECT OPTION VALUE THE CERTAIN HEADER SHOULD APPEAR IN THE DATATABLE. THE DATATABLE IN THE BEGGININ SHOULD BE EMPTY. IF FOR EXAMPLE I I WANT TO SHOW THE SECOND HEADER, THEN IT WOULD APPEAR.
I KNOW THERE IS A SIMILAR CHOICE ONLINE IN WHICH THE DATATABLE IS NOT EMPTY, BUT INITIALIZED AND CLICKING ON SELECT IT TOGGLES THE CERTAIN HEADER. SO I WANT TO DO IT THE OTHER WAY IT.
This question has an accepted answers - jump to answer
Answers
THIS IS THE MULTISELECT PLUGIN. IF I CLICK A CERTAIN OPTION THE CURRENT CLICKED OPTION PASSES ON THE OTHER SIDE AND THE RESPECTIVE HEADER ON THE DATATABLE SHOULD APPEAR AND IF I CLICK ITS LABEL ALL HEADERS SHOULD APPEAR.
No need to shout
Sure - use
row().remove()
androw.add()
to delete / add data as required. You can usetable1.row({selected: true}).data()
to get the data for the selected row and then add it to the other table for example.Allan
Thank u and i will keep you up to date if it worked