split button wrapper div doesn't get the class assigned
split button wrapper div doesn't get the class assigned

I have this split button:
ctrTable.button().add( 3, {
extend: "editPSCData", className: "editorOnly", name: "editPSCVatDataButton",
split: [
{ extend: "editPSCData", name: "editPSCPreTaxDataButton",
text: lang === 'de' ? 'VSt.-Check §15 UStG' : 'Input tax check §15 UStG'},
{ extend: "editPSCData", name: "editPSCPreTaxCorrectionButton", className: "hidden",
text: lang === 'de' ? 'VSt.-Korrektur §15a UStG' : 'Input tax adjustmt. §15a UStG'}
]
} );
When I ran this code:
if ( ! isCtrEditor ) {
ctrTable.buttons('.editorOnly').nodes().addClass('hidden');
}
which means, if the user is not entitled to edit a contract the "editorOnly" buttons should be hidden.
That didn't work for the split button. While the two buttons in the dropdown of the split button were hidden the wrapper div containing the first or "main" button was not hidden because the class "editorOnly" wasn't assigned to the wrapper div by Data Tables.
I added this workaround to make it work:
$('div.dt-btn-split-wrapper > button.editorOnly').parent().addClass("editorOnly");
I think this is a bug.
This question has an accepted answers - jump to answer
Answers
Interesting one - thanks for posting this. I need to have a bit of a think about it. It looks like a flaw in the API
.
Great to hear you have a workaround for the moment!
Allan
I also implemented another split button workaround a while ago. That workaround was not like the one above (i.e. adding the class "manually") but it was assigning a "name" to the split button in addition to the "class" and refer to the name instead of the class.
This line of code removes all buttons that have the class "notTConly" or the name "excelSplitButton".
This is the split button definition. I had to add the "name" to be able to remove this button. "className" is being ignored because the wrapper div doesn't get the "class" assigned, only the "name".
Since "name" works and "className" doesn't, it should be easier for you to find the bug, Allan. I hope
.
Roland