Problems with Disabling Column Control for Specific Columns
Problems with Disabling Column Control for Specific Columns
Link to test case: https://live.datatables.net/hifoyuza/1/
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:
var table = new DataTable('#example',
{
columnControl: [ { target: 0, content: [ 'orderAsc' ] }, { target: 1, content: [ 'search' ] } ],
columnDefs: [{
target: -1,
columnControl: []
},
]
});
I'm having problems do disable column control on specfic columns when column control has been initiated with a target of 2 header rows, as shown in the example above.
How can I use column specific column control in use cases like this?
This question has an accepted answers - jump to answer
Answers
See this thread for the answer. Basically you need to specify the target both header rows in
columns.columnControl.Your test case doesn't run because it is loading Datatables 3 but you are loading ColumnControl 1,2.1 which only works with DT 2. I updated the test case to use DT 2 and to show how to apply
columns.columnControlwhen multiple header rows are defined.https://live.datatables.net/hifoyuza/2/edit
For example:
Kevin
Thanks for the suggestion.
The other thread was insightful and with your answer I'm now able to disable columncontrol for the last column, as expected. But for some reason it does only work for me when I'm using a predfined HTML table or explicit sets the data inte the data options variable.
My problem still persists when I'm getting data through ajax, or so it seems. Will try to create a external setup where my problem still is showing.
Sorry, you can disregard my last comment, when testing I missed that I have several columns not visible, so the column I'was targeting was actually not visible.
So thanks again, your suggested solution works for me, even for ajax loaded columns
Super - thanks for the update. Good to hear you've got it working now.
Allan