Row count of filtered rows

Row count of filtered rows

jacomojacomo Posts: 2Questions: 2Answers: 0
edited August 2018 in Free community support

Hello, I need to count the rows displayed after filtering the table, I am using the page.info api but I always get the same number for displayed with the total rows.
var info = table1.page.info();
var rowstot = info.recordsTotal;
var rowsshown = info.recordsDisplay;

Is it a bug maybe? Thank you

Answers

  • rf1234rf1234 Posts: 2,801Questions: 85Answers: 406

    Hi, I tried this code and it worked perfectly fine:

    myTable
        .on('select', function (e, dt, type, indexes) {  
            var info = myTable.page.info();
            var rowstot = info.recordsTotal;
            var rowsshown = info.recordsDisplay;
            alert("rowstot: " + rowstot);
            alert("rowsshown: " + rowsshown);
        });
    

    And this is my table footer:

    Showing 1 to 1 of 1 entries (filtered from 2 total entries) Click row to select

    Hence 1 was being alerted as rowsshown and 2 as rowstot.

    Something else must be wrong with your code. You might initialize rowstot and rowsshown too early, before the filter is being applied?!

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hi @jacomo ,

    Use the recordsDisplay as shown in this example,

    Cheers,

    Colin

This discussion has been closed.