I'm getting an error "Object doesn't support property or method 'column'. How do I fix this?

I'm getting an error "Object doesn't support property or method 'column'. How do I fix this?

kmh158kmh158 Posts: 5Questions: 1Answers: 0

I'm running the same code on IE11 using sharepoint 2013. I used the same example of coding that you have provided. I couldn't find anything to fix this issue.

Answers

  • kmh158kmh158 Posts: 5Questions: 1Answers: 0

    $('#example thead tr').clone(true).appendTo( '#example thead' );
    $('#example thead tr:eq(1) th').each( function (i) {
    var title = $(this).text();
    $(this).html( '<input type="text" placeholder="Search '+title+'" />' );

        $( 'input', this ).on( 'keyup change', function () {
            if ( table.column(i).search() !== this.value ) {
                table
                    .column(i)
                    .search( this.value )
                    .draw();
            }
        } );
    

    This what I'm using

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin

    I don't see where you are defining your table variable. Please could you post a link to a test case showing the issue per the forum rules?

    My guess is that you are using $().dataTable() rather than $().DataTable() as noted in the top FAQ.

    Allan

  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954

    My guess is the problem is with table.column(i) in line 2. What does the variable table contain? In your code it is expected to be the Datatables API, ie, var table = $('#myTable').DataTable();. Seems like it must be something else.

    Hard to say without seeing it. Please post a link to your page or a test case so we can take a look.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • kmh158kmh158 Posts: 5Questions: 1Answers: 0

    this what I have for "table"

    var $tabel = $('#mytable');
    var $parent = $table.children('tbody');
    var table = $table.dataTable();

  • kmh158kmh158 Posts: 5Questions: 1Answers: 0
    edited October 2019

    var $tabel = $('#mytable');

    var $parent = $table.children('tbody');

    var table = $table.dataTable();

    $('#example thead tr').clone(true).appendTo( '#example thead' );

    $('#example thead tr:eq(1) th').each( function (i)
    {
    var title = $(this).text();
    $(this).html( '<input type="text" placeholder="Search '+title+'" />' );

    $( 'input', this ).on( 'keyup change', function () {
    if ( table.column(i).search() !== this.value ) {
    table
    .column(i)
    .search( this.value )
    .draw();
    }
    } );
    });

    This the how the code looks like that I have

  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954

    var table = $table.dataTable(); needs to be var table = $table.DataTable(); to use the API. Note the D in `DataTable. Please see this FAQ for more details.

    Kevin

  • kmh158kmh158 Posts: 5Questions: 1Answers: 0

    I changed it to DataTable(), but it's still giving me the same error

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @kmh158 ,

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954
    edited October 2019
    var $tabel = $('#mytable');
    
    var $parent = $table.children('tbody');
    
    var table = $table.dataTable();
    

    Looks like a typo. In line 1 you have $label and in line 5 you have $table. If this doesn't help then as Colin mentions we will need to see it.

    Kevin

This discussion has been closed.