RowGroup enable option dependent on ajax request data

RowGroup enable option dependent on ajax request data

andyovandyov Posts: 7Questions: 3Answers: 0

I have a DataTable which uses Ajax, and I also use the RowGroup plugin. The RowGroup.enable option is dependent based n data from the ajax call, i.e. if there is only one group, I want to hide the row grouping.

Just wondering if there is any way to pass the boolean from the ajax request to the RowGroup.enable flag during initialisation?

I've included a rough idea of what I'm going for below:

var do_not_group=true
$('table').DataTable({
ajax: function(data, callback,settings){
...
if(data.group.length<=1){
do_not_group=true
}
.....

rowGroup:{
enable: !do_not_group

Thanks,
Andy

Answers

  • andyovandyov Posts: 7Questions: 3Answers: 0
    edited October 2019

    Just realised I can use the preDraw event to check the do_not_group flag and call datatable.rowGroup().disable() as necessary

This discussion has been closed.