jquery-datatables-checkboxes: Cannot read property 'checkboxes' of undefined

With the updated code I think I found a bug. Previously with the older code it worked. I have an external button that “clicks” the select all button, something like this:

$('.bulk-actions .btn--selection').on('click', function(e){
     $('.dt-checkboxes-select-all').trigger('click');
});

The click event itself works, I see the checkboxes change and the $(table.table().container()).on('change', 'input[type="checkbox"]', function() { grabs the count, but it throws and error as well:

screen shot 2017-02-01 at 14 44 30

Lines may not correspond, because I’m playing around with custom checkboxes from bootstrap, mentioned that a while back to you, but you’re still having doubts. Maybe I’ll make a pull request later.

The lines in my case are:

275: self.onClickSelectAll(e, this); 545: (ctx.aoColumns[col].checkboxes && ctx.aoColumns[col].checkboxes.selectAllPages)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I agree, it’s not the best extension. I will try to contact allan and see what he says. I wanted to stick to css solution in the beginning, but it was really hard to apply on datatable, scrollY stopped working with it etc. Can’t have mile long tables on pages.

For my system it’s hard to avoid it because Responsive extension just doesn’t cut it, clients have the ability to select what data they want to see, so basically when you select 20 columns, you need to somehow see them and not hide them.

By the way, if anyone will be interested in external click button for the click all, had to tweak it a bit, since you need to consider “not clicked” when having a server-side solution:

var select_all = $(table.table().container()).find('.dt-checkboxes-select-all input');
                    if(select_all.prop('indeterminate') || !select_all.prop('checked')) {
                        table.column(0).checkboxes.select();
                    } else {
                        table.column(0).checkboxes.deselect();
                    }

                    select_all.trigger('change');
 });