display row count in html page

display row count in html page

Alex2019Alex2019 Posts: 62Questions: 9Answers: 0
edited July 2019 in Free community support

I would like to count the number of rows and display the result in the html code

id="perftabs"> Performer Credits (row result)

Replies

  • kthorngrenkthorngren Posts: 20,257Questions: 26Answers: 4,761

    You can use the count() API to get the number of rows. The examples should get you started.

    Kevin

  • Alex2019Alex2019 Posts: 62Questions: 9Answers: 0

    I have to visualize the result of the record also in the web page, in a point I specified in the code

    this
    ) id="perftabs"> Performer Credits (row result) )

    I now see below the table cells

    the example I did not understand :/

  • kthorngrenkthorngren Posts: 20,257Questions: 26Answers: 4,761

    You would use something like this:

    var table = $('#example').DataTable();
     
    var numRows = table.rows( ).count();
    
    

    Then you would use jQuery or your preferred method to place the value of numRows on the web page. Something like this example:
    https://datatables.net/extensions/select/examples/api/get.html

    Now the question si when do you want to display that info? After a button click like the select example?

    After the Datatable has initialized? You could use initComplete, something like this:

    $('#example').dataTable( {
      "initComplete": function(settings, json) {
          var api = this.api();
          var numRows = api.rows( ).count();
          // Place the value in your HTML using jQuery, etc
      }
    } );
    

    Kevin

  • Alex2019Alex2019 Posts: 62Questions: 9Answers: 0

    Hi kthorngren :)

    the count must occur when I open the page

    look this screen

    https://yadi.sk/i/bLLNfDVU5X-ODw

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @Alex2019 ,

    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

This discussion has been closed.