count item filtered and show in the page

count item filtered and show in the page

m75sam75sa Posts: 132Questions: 30Answers: 0
edited April 2022 in Free community support

Hi all,
I'm searching a way to count items filtered and show the result in the html page, on the bottom or on the top.
For example if you see this demo:
http://live.datatables.net/geconesi/1/

what I need is a box or something else, on the bottom/top area of the page, that catch dynamically the total number of each single column of the table... do you think can be possible?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,237Questions: 1Answers: 10,418 Site admin

    Do you mean like shown in this example?

    Allan

  • m75sam75sa Posts: 132Questions: 30Answers: 0

    yes, quite the same but:
    i need total for each column and to be placed in different part of the page.. so i can display the single totale not forcibly under the column but also in other part of the page... possible?

  • m75sam75sa Posts: 132Questions: 30Answers: 0
    edited April 2022

    to be more precisely i'm going to create a div... or a block, under the table that must contains all totals displayed from the table. .. and the values of course will change dynamically from the table select filter...

  • kthorngrenkthorngren Posts: 21,184Questions: 26Answers: 4,925

    This is the code that updates the HTML:

                // Update footer
                $( api.column( 4 ).footer() ).html(
                    '$'+pageTotal +' ( $'+ total +' total)'
                );
    

    You can change the selector (api.column( 4 ).footer()) with any selector you wish. Doesn't have to be in the footer. If it makes more sense to you that foorterCallback code can be moved into drawCallback.

    Kevin

  • m75sam75sa Posts: 132Questions: 30Answers: 0
    edited April 2022

    thanks to your help i discover the possibility to add values outside the table.
    What i'm still down is to adapt your script to that one that searches on each columns.

    So script edited is:
    live.datatables.net/geconesi/2/edit

    but i cannot adapt it to this one:
    live.datatables.net/geconesi/3/edit

    where do i wrong?
    If i add the bloc inside the function it doesn't work...
    live.datatables.net/geconesi/3/edit

    and in particular i would like to display the total of each column row...
    any help?
    Thanks a lot my friend!

  • m75sam75sa Posts: 132Questions: 30Answers: 0

    Hi @kthorngren ,
    i found this:
    https://datatables.net/forums/discussion/59587/count-number-of-searched-rows-after-dropdown-menu-changes

    but i was not able to replicate the sample... any help?

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    This example is counting both the filtered and non-filtered, that should get you going,

    Colin

Sign In or Register to comment.