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

Deselect All Checkboxes Except Current - Not working on Pages > 1

$
0
0

I want the code to deselect anything but the current selection, and to deselect anything checked on other pages.. If I set all the checkboxes to false, the code only works from the first page, not from any pages > 1

@Styles.Render("~/Content/DataTables")
@Scripts.Render("~/bundles/DataTables")

<script>

 $(document).ready(function () {
        $('#results').DataTable({
            columnDefs: [
                {
                    className: 'dt-nowrap',
                    targets: 1
                },
                {
                    className: 'dt-center',
                    targets: [1,2]
                }
            ],
            "paging": true,
            "pageLength": 10,
            "lengthMenu": [[10, 20, 40, -1], [10, 20, 40, "All"]],
            "order": [[0, "asc"]],
            "searching": false,
            "sort": false,
            "deferRender": true
        });

        //prevent enter from submitting form
        $(document).keydown(function (e) {
            if (e.keyCode == 13) {
                return false;
            }
        });
 
    });

    $(function () {
        $("input").change(function (e) {
            e.preventDefault();
            var table = $('#results').dataTable();
            $('input', table.fnGetNodes()).prop('checked', false);
            $(this).prop("checked", true);
        });

</script>

The bundles are as follows:

    bundles.Add(New StyleBundle("~/Content/DataTables").Include(
                "~/DataTables/datatables.min.css"))

    bundles.Add(New ScriptBundle("~/bundles/DataTables").Include(
                "~/DataTables/datatables.min.js"))

What am I doing wrong, or rather, what is the correct way to resolve this?


Viewing all articles
Browse latest Browse all 82031

Trending Articles



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