Object doesn't support property or method 'column'

Object doesn't support property or method 'column'

pfiorellapfiorella Posts: 8Questions: 2Answers: 0
edited July 2014 in Free community support

Object doesn't support property or method 'column'

I get this error trying to run the following code:

var name = $("#monthFilter option:selected").text();
table.column(7).search(name).draw();

Before you tell me to read the FAQs, I did check to make sure I'm using the correct initialization of the table, that is:

 var table = $('#tblForecast').DataTable();

as opposed to:

var table = $('#tblForecast').dataTable();

And still no luck. Am I missing something obvious?

This question has an accepted answers - jump to answer

Answers

  • DaimianDaimian Posts: 62Questions: 1Answers: 15
    Answer ✓

    Your correct, you are using it correctly.
    My only thought was you are accidentally overwritting table variable after initialization?

  • pfiorellapfiorella Posts: 8Questions: 2Answers: 0
    edited July 2014

    Here's my entire script:

    <script type="text/javascript">
    
        $(document).ready(function () {
            var table = $('#tblForecast').DataTable({
                "sPaginationType": "full_numbers",
                "bJQueryUI": true,
                "fnDrawCallback": calculateTotal,
                "bPaginate": true,
                "iDisplayLength": 100
            }); //end table init
    
    
    
            $('#monthFilter').change(function () {
                var name = $("#monthFilter option:selected").text();
                if (name !== "No Filter") {
                   table.column(7).search(name).draw();
                } else {
                    table.column(7).search("").draw();
                }
            }); //end change
    
        });//end ready
    
    </script>
    
  • pfiorellapfiorella Posts: 8Questions: 2Answers: 0

    I figured it out. I have 3 separate instances of DataTables on the same page and they had conflicting code, doh! Thanks!

This discussion has been closed.