Unable to Filter rows using Checkbox (Sharepoint Online)

Unable to Filter rows using Checkbox (Sharepoint Online)

2008jackson2008jackson Posts: 38Questions: 9Answers: 0

Greetings,

I have successfully implemented datatables on Sharepoint Online. Data is pulled through RESTAPI. I now have a requirement to filter rows with values "Vendors" in Tags column. However, on clicking the checkbox, my Chrome console throws out the following error.

Uncaught ReferenceError: table is not defined
at HTMLInputElement.<anonymous> (Links.aspx:630)
at HTMLInputElement.dispatch (jquery-3.5.1.js:5429)
at HTMLInputElement.elemData.handle (jquery-3.5.1.js:5233)
(anonymous) @ Links.aspx:630
dispatch @ jquery-3.5.1.js:5429
elemData.handle @ jquery-3.5.1.js:5233

JS Fiddle @ https://jsfiddle.net/3zrdt05y/

Kindly assist.

This question has an accepted answers - jump to answer

Answers

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

    Your test case doesn't run. You need to define the variable table which you want to be an instance of the Datatables API. Like this:

        $('input:checkbox').on('change', function () {
            var table =  $('#table_id').DataTable();
            table.draw();
        });     
    

    Or you can do this on the line with your Datatable initialization like this example.

    Kevin

  • 2008jackson2008jackson Posts: 38Questions: 9Answers: 0

    Worked perfectly! Thankyou @kthorngren

This discussion has been closed.