How to add select box

How to add select box

CountLessQCountLessQ Posts: 33Questions: 9Answers: 0

I am trying to add a check box to each row following the answer in this link
How ever it throws a .Datatables function not defined error.
Here is my code
Thank you..

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    Your example doesn't have code from either of the two options provided in the link you mentioned. Plus its not showing the error.

    Please update your example to show the problem.

    Kevin

  • CountLessQCountLessQ Posts: 33Questions: 9Answers: 0
    edited October 2020

    @kthorngren I though it would be better to leave it out. Here is a link
    Thank you

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    These are in the wrong order and causing an error shown in the browser's console:

        <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js"></script>
        <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.6/js/jquery.dataTables.js"></script>
    

    select.js depends on datatables.js so load it after datatables.js.

    Looks like you are trying to setup this example:
    https://datatables.net/extensions/select/examples/initialisation/checkbox.html

    You need to add a column to your table for the select checkbox and add this code to display the checkbox:

            columnDefs: [ {
                orderable: false,
                className: 'select-checkbox',
                targets:   0
            } ],
    

    Kevin

  • CountLessQCountLessQ Posts: 33Questions: 9Answers: 0

    @kthorngren i followed the steps and this is what i am stuck with
    How do i make the Js attach the search box to on column or individual columns?
    Thank you.

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923
    edited October 2020 Answer ✓

    Another problem is you are loading an old version of Datatables, 1.10.6. I newer version is needed for the select extension. Here is an example with the select checkbox:
    http://live.datatables.net/henovunu/1/edit

    I changed you header search to something a bit easier to create. I did the following:
    1. Removed the CSS you had to move the footer
    2. added a second header and a classname of search to the columns to apply the search
    3. used orderCellsTop to force the sorting to the top header row

    Kevin

  • CountLessQCountLessQ Posts: 33Questions: 9Answers: 0

    @kthorngren Thank you a lot.

This discussion has been closed.