Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82464

How to Select All up to max limit using Gyrocode checkboxes plugin

$
0
0

Hello!

I am using the Gyrocode checkboxes plugin, and I've run into a situation where I am trying to have a maximum number of selected rows and the select All checkbox does not trigger the function I put in place.
I'm using a server-side data source.

Here is what I added (trying to include just the relevant part, let me know if I should include more):

        table.on('select', function (e, dt, type, ix) {
            var selected = dt.column(0).checkboxes.selected();
            if (selected.count() > 5) {
                dt.rows(ix).deselect();
                alert("A maximum of 50 records can be added to a single document.");
            }
        });

The above works great when manually checking the boxes (it prevents the user from selecting more than 5). When checking the Select All box, though, it selects all of the items on the page (10), so obviously it's not triggering the above function.

I'm sure this is just a matter of adding something similar to that .on() method, but I'm not sure what. I checked [here] but I don't have an intuition for how to use these options.

Thank you!

(https://www.gyrocode.com/projects/jquery-datatables-checkboxes/reference/options/#columns.checkboxes.selectAllCallback "here ")


Viewing all articles
Browse latest Browse all 82464

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>