Jquery Datatable: Object doesn't support property or method 'Draw' asp.net












0















using the following code:



HTML:



  <head runat="server">
<title>datatable loading searching, sorting and updating </title>
<link rel="stylesheet" type="text/css" href="css/jquery.dataTables.min.css" />
<link rel="stylesheet" type="text/css" href="scroller.dataTables.min.css" />

<script src="js/jquery-3.3.1.js")%>" type="text/javascript"></script>
<script src="js/jquery.dataTables.min.js")%>" type="text/javascript"></script>


HTML:



        <script type="text/javascript">
$(document).ready(function () {
BindCompanyTable();
//Adding Data manually to datatable
appendCompanyData()
// this is for document ready
});


function BindCompanyTable() {

myTable = $("#tblCompany").DataTable({
"deferRender": true,
"paging": true,
"lengthChange": false,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": false,
"sDom": 'lfrtip'
//"sPaginationType" : "full_numbers"
});
}

function appendCompanyData() {
alert('inside appendCompanyData');
//'DATA SHOWING'
var companytable = $('#tblCompany tbody');
companytable.append('<tr><td>1 </td><td> CompanyA</td><td>Bryant</td></tr>');
companytable.append('<tr><td>2 </td><td> CompanyB</td><td>Little Rock</td></tr>');
companytable.append('<tr><td>3 </td><td> CompanyC</td><td>Little Rock</td></tr>');
companytable.append('<tr><td>4 </td><td> CompanyD</td><td>Little Rock</td></tr>');
companytable.append('<tr><td>5 </td><td> CompanyE</td><td>Little Rock</td></tr>');

//this line is giving an error
//Error: Object doesn't support property or method 'Draw'

companytable.Draw();

}

</script>

</head >



<table id="tblCompany" border="1" style="border-collapse:">
<thead>
<tr>
<th id="thcompany">CompanyRecordID</th>
<th>CompanyName</th>
<th>City</th>
</tr>
</thead>
<tbody></tbody>
</table>


Displaying 5 rows using jquery Datatable and I want to check how search and ordering works with datatable. The data shows up on the form but I get the error above on this line of code:



companytable.Draw(); 



Error: Object doesn't support property or method 'Draw'




Also,as I type a keyword in search input box, the 5 data rows disappears and I see this: "No data available in table" showing inside data table.



the Data table column header are showing OK



Am I missing a Jquery plug in or may not adding the correct Plug in.










share|improve this question





























    0















    using the following code:



    HTML:



      <head runat="server">
    <title>datatable loading searching, sorting and updating </title>
    <link rel="stylesheet" type="text/css" href="css/jquery.dataTables.min.css" />
    <link rel="stylesheet" type="text/css" href="scroller.dataTables.min.css" />

    <script src="js/jquery-3.3.1.js")%>" type="text/javascript"></script>
    <script src="js/jquery.dataTables.min.js")%>" type="text/javascript"></script>


    HTML:



            <script type="text/javascript">
    $(document).ready(function () {
    BindCompanyTable();
    //Adding Data manually to datatable
    appendCompanyData()
    // this is for document ready
    });


    function BindCompanyTable() {

    myTable = $("#tblCompany").DataTable({
    "deferRender": true,
    "paging": true,
    "lengthChange": false,
    "searching": true,
    "ordering": true,
    "info": true,
    "autoWidth": false,
    "sDom": 'lfrtip'
    //"sPaginationType" : "full_numbers"
    });
    }

    function appendCompanyData() {
    alert('inside appendCompanyData');
    //'DATA SHOWING'
    var companytable = $('#tblCompany tbody');
    companytable.append('<tr><td>1 </td><td> CompanyA</td><td>Bryant</td></tr>');
    companytable.append('<tr><td>2 </td><td> CompanyB</td><td>Little Rock</td></tr>');
    companytable.append('<tr><td>3 </td><td> CompanyC</td><td>Little Rock</td></tr>');
    companytable.append('<tr><td>4 </td><td> CompanyD</td><td>Little Rock</td></tr>');
    companytable.append('<tr><td>5 </td><td> CompanyE</td><td>Little Rock</td></tr>');

    //this line is giving an error
    //Error: Object doesn't support property or method 'Draw'

    companytable.Draw();

    }

    </script>

    </head >



    <table id="tblCompany" border="1" style="border-collapse:">
    <thead>
    <tr>
    <th id="thcompany">CompanyRecordID</th>
    <th>CompanyName</th>
    <th>City</th>
    </tr>
    </thead>
    <tbody></tbody>
    </table>


    Displaying 5 rows using jquery Datatable and I want to check how search and ordering works with datatable. The data shows up on the form but I get the error above on this line of code:



    companytable.Draw(); 



    Error: Object doesn't support property or method 'Draw'




    Also,as I type a keyword in search input box, the 5 data rows disappears and I see this: "No data available in table" showing inside data table.



    the Data table column header are showing OK



    Am I missing a Jquery plug in or may not adding the correct Plug in.










    share|improve this question



























      0












      0








      0








      using the following code:



      HTML:



        <head runat="server">
      <title>datatable loading searching, sorting and updating </title>
      <link rel="stylesheet" type="text/css" href="css/jquery.dataTables.min.css" />
      <link rel="stylesheet" type="text/css" href="scroller.dataTables.min.css" />

      <script src="js/jquery-3.3.1.js")%>" type="text/javascript"></script>
      <script src="js/jquery.dataTables.min.js")%>" type="text/javascript"></script>


      HTML:



              <script type="text/javascript">
      $(document).ready(function () {
      BindCompanyTable();
      //Adding Data manually to datatable
      appendCompanyData()
      // this is for document ready
      });


      function BindCompanyTable() {

      myTable = $("#tblCompany").DataTable({
      "deferRender": true,
      "paging": true,
      "lengthChange": false,
      "searching": true,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "sDom": 'lfrtip'
      //"sPaginationType" : "full_numbers"
      });
      }

      function appendCompanyData() {
      alert('inside appendCompanyData');
      //'DATA SHOWING'
      var companytable = $('#tblCompany tbody');
      companytable.append('<tr><td>1 </td><td> CompanyA</td><td>Bryant</td></tr>');
      companytable.append('<tr><td>2 </td><td> CompanyB</td><td>Little Rock</td></tr>');
      companytable.append('<tr><td>3 </td><td> CompanyC</td><td>Little Rock</td></tr>');
      companytable.append('<tr><td>4 </td><td> CompanyD</td><td>Little Rock</td></tr>');
      companytable.append('<tr><td>5 </td><td> CompanyE</td><td>Little Rock</td></tr>');

      //this line is giving an error
      //Error: Object doesn't support property or method 'Draw'

      companytable.Draw();

      }

      </script>

      </head >



      <table id="tblCompany" border="1" style="border-collapse:">
      <thead>
      <tr>
      <th id="thcompany">CompanyRecordID</th>
      <th>CompanyName</th>
      <th>City</th>
      </tr>
      </thead>
      <tbody></tbody>
      </table>


      Displaying 5 rows using jquery Datatable and I want to check how search and ordering works with datatable. The data shows up on the form but I get the error above on this line of code:



      companytable.Draw(); 



      Error: Object doesn't support property or method 'Draw'




      Also,as I type a keyword in search input box, the 5 data rows disappears and I see this: "No data available in table" showing inside data table.



      the Data table column header are showing OK



      Am I missing a Jquery plug in or may not adding the correct Plug in.










      share|improve this question
















      using the following code:



      HTML:



        <head runat="server">
      <title>datatable loading searching, sorting and updating </title>
      <link rel="stylesheet" type="text/css" href="css/jquery.dataTables.min.css" />
      <link rel="stylesheet" type="text/css" href="scroller.dataTables.min.css" />

      <script src="js/jquery-3.3.1.js")%>" type="text/javascript"></script>
      <script src="js/jquery.dataTables.min.js")%>" type="text/javascript"></script>


      HTML:



              <script type="text/javascript">
      $(document).ready(function () {
      BindCompanyTable();
      //Adding Data manually to datatable
      appendCompanyData()
      // this is for document ready
      });


      function BindCompanyTable() {

      myTable = $("#tblCompany").DataTable({
      "deferRender": true,
      "paging": true,
      "lengthChange": false,
      "searching": true,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "sDom": 'lfrtip'
      //"sPaginationType" : "full_numbers"
      });
      }

      function appendCompanyData() {
      alert('inside appendCompanyData');
      //'DATA SHOWING'
      var companytable = $('#tblCompany tbody');
      companytable.append('<tr><td>1 </td><td> CompanyA</td><td>Bryant</td></tr>');
      companytable.append('<tr><td>2 </td><td> CompanyB</td><td>Little Rock</td></tr>');
      companytable.append('<tr><td>3 </td><td> CompanyC</td><td>Little Rock</td></tr>');
      companytable.append('<tr><td>4 </td><td> CompanyD</td><td>Little Rock</td></tr>');
      companytable.append('<tr><td>5 </td><td> CompanyE</td><td>Little Rock</td></tr>');

      //this line is giving an error
      //Error: Object doesn't support property or method 'Draw'

      companytable.Draw();

      }

      </script>

      </head >



      <table id="tblCompany" border="1" style="border-collapse:">
      <thead>
      <tr>
      <th id="thcompany">CompanyRecordID</th>
      <th>CompanyName</th>
      <th>City</th>
      </tr>
      </thead>
      <tbody></tbody>
      </table>


      Displaying 5 rows using jquery Datatable and I want to check how search and ordering works with datatable. The data shows up on the form but I get the error above on this line of code:



      companytable.Draw(); 



      Error: Object doesn't support property or method 'Draw'




      Also,as I type a keyword in search input box, the 5 data rows disappears and I see this: "No data available in table" showing inside data table.



      the Data table column header are showing OK



      Am I missing a Jquery plug in or may not adding the correct Plug in.







      jquery html asp.net datatable






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 1 at 8:54









      James Z

      11.2k71935




      11.2k71935










      asked Jan 1 at 1:14









      user3225726user3225726

      116




      116
























          2 Answers
          2






          active

          oldest

          votes


















          1














          You are calling draw method on table tbody instead of table



          var companytable = $('#tblCompany tbody');


          Instead, you should be calling it on tblCompany element like this:



          $('tblCompany').draw()


          Also, I am not sure why you have %> at the end of src attribute in script tags



          <script src="js/jquery-3.3.1.js")%>" type="text/javascript"></script>
          <script src="js/jquery.dataTables.min.js")%>" type="text/javascript"></script>





          share|improve this answer

































            0














            I resolved this by using the following line of code:



            var ctable = new $.fn.dataTable.Api('#tblCompany');
            ctable.draw();



            Also the %> at the end of src attribute in script tags was left my mistake because the line of code was copied from another line of code with this syntax.



            " type="text/javascript">

            then later I removed the ResolveUrl
            Just a typing error






            share|improve this answer
























            • I am not sure how your answer is different from the one provided above. $('tblCompany').draw() should do the trick as well.

              – Mohsin Mehmood
              Jan 10 at 5:53











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53992455%2fjquery-datatable-object-doesnt-support-property-or-method-draw-asp-net%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You are calling draw method on table tbody instead of table



            var companytable = $('#tblCompany tbody');


            Instead, you should be calling it on tblCompany element like this:



            $('tblCompany').draw()


            Also, I am not sure why you have %> at the end of src attribute in script tags



            <script src="js/jquery-3.3.1.js")%>" type="text/javascript"></script>
            <script src="js/jquery.dataTables.min.js")%>" type="text/javascript"></script>





            share|improve this answer






























              1














              You are calling draw method on table tbody instead of table



              var companytable = $('#tblCompany tbody');


              Instead, you should be calling it on tblCompany element like this:



              $('tblCompany').draw()


              Also, I am not sure why you have %> at the end of src attribute in script tags



              <script src="js/jquery-3.3.1.js")%>" type="text/javascript"></script>
              <script src="js/jquery.dataTables.min.js")%>" type="text/javascript"></script>





              share|improve this answer




























                1












                1








                1







                You are calling draw method on table tbody instead of table



                var companytable = $('#tblCompany tbody');


                Instead, you should be calling it on tblCompany element like this:



                $('tblCompany').draw()


                Also, I am not sure why you have %> at the end of src attribute in script tags



                <script src="js/jquery-3.3.1.js")%>" type="text/javascript"></script>
                <script src="js/jquery.dataTables.min.js")%>" type="text/javascript"></script>





                share|improve this answer















                You are calling draw method on table tbody instead of table



                var companytable = $('#tblCompany tbody');


                Instead, you should be calling it on tblCompany element like this:



                $('tblCompany').draw()


                Also, I am not sure why you have %> at the end of src attribute in script tags



                <script src="js/jquery-3.3.1.js")%>" type="text/javascript"></script>
                <script src="js/jquery.dataTables.min.js")%>" type="text/javascript"></script>






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 1 at 6:05

























                answered Jan 1 at 5:18









                Mohsin MehmoodMohsin Mehmood

                2,4262513




                2,4262513

























                    0














                    I resolved this by using the following line of code:



                    var ctable = new $.fn.dataTable.Api('#tblCompany');
                    ctable.draw();



                    Also the %> at the end of src attribute in script tags was left my mistake because the line of code was copied from another line of code with this syntax.



                    " type="text/javascript">

                    then later I removed the ResolveUrl
                    Just a typing error






                    share|improve this answer
























                    • I am not sure how your answer is different from the one provided above. $('tblCompany').draw() should do the trick as well.

                      – Mohsin Mehmood
                      Jan 10 at 5:53
















                    0














                    I resolved this by using the following line of code:



                    var ctable = new $.fn.dataTable.Api('#tblCompany');
                    ctable.draw();



                    Also the %> at the end of src attribute in script tags was left my mistake because the line of code was copied from another line of code with this syntax.



                    " type="text/javascript">

                    then later I removed the ResolveUrl
                    Just a typing error






                    share|improve this answer
























                    • I am not sure how your answer is different from the one provided above. $('tblCompany').draw() should do the trick as well.

                      – Mohsin Mehmood
                      Jan 10 at 5:53














                    0












                    0








                    0







                    I resolved this by using the following line of code:



                    var ctable = new $.fn.dataTable.Api('#tblCompany');
                    ctable.draw();



                    Also the %> at the end of src attribute in script tags was left my mistake because the line of code was copied from another line of code with this syntax.



                    " type="text/javascript">

                    then later I removed the ResolveUrl
                    Just a typing error






                    share|improve this answer













                    I resolved this by using the following line of code:



                    var ctable = new $.fn.dataTable.Api('#tblCompany');
                    ctable.draw();



                    Also the %> at the end of src attribute in script tags was left my mistake because the line of code was copied from another line of code with this syntax.



                    " type="text/javascript">

                    then later I removed the ResolveUrl
                    Just a typing error







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jan 9 at 23:29









                    user3225726user3225726

                    116




                    116













                    • I am not sure how your answer is different from the one provided above. $('tblCompany').draw() should do the trick as well.

                      – Mohsin Mehmood
                      Jan 10 at 5:53



















                    • I am not sure how your answer is different from the one provided above. $('tblCompany').draw() should do the trick as well.

                      – Mohsin Mehmood
                      Jan 10 at 5:53

















                    I am not sure how your answer is different from the one provided above. $('tblCompany').draw() should do the trick as well.

                    – Mohsin Mehmood
                    Jan 10 at 5:53





                    I am not sure how your answer is different from the one provided above. $('tblCompany').draw() should do the trick as well.

                    – Mohsin Mehmood
                    Jan 10 at 5:53


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53992455%2fjquery-datatable-object-doesnt-support-property-or-method-draw-asp-net%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith