how to exclude a row from total count of pagination or how to exclude a row from total count

how to exclude a row from total count of pagination or how to exclude a row from total count

lenamtllenamtl Posts: 265Questions: 65Answers: 1

Hi,

is there a way to ignore a row in total count pagination
let say I have 11 rows total but I don't want to include the first row into the total pagination
so I have 11 row but it should do count() minus 1 or if there is a way to exclude it from the total pagination count so the result will be total -1

let me know if this is not clear.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,587

    If it's there, it'll be counted. You could remove it with row().remove()

    Cheers,

    Colin

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1
    edited October 2019

    Hi,

    I need that row to be visible but not counted.
    So I don't think row().remove() is the solution
    is there a way to take the pagination count and do minus 1 so I will end with the correct total of row

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,774

    If you are referring to the information element, Showing 1 to 10 of 57 entries for example, you would likely need to create your own. One way to do this would be to use the dom option to remove it by removing the i. Then use the draw event to display and update your own HTML element. You can get the page info using the page.info() API to update the element.

    Kevin

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1

    How could I modify the"recordsTotal": 57, value by doing -1
    so the result will be displayed as 56

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,774
    edited October 2019 Answer ✓

    Something like this to help you get started:
    http://live.datatables.net/fajuwate/2/edit

    You will need to add more logic to display things like Showing 1 to 10 of 42 entries (filtered from 57 total entries) when searching etc.

    You won't be able to directly subtract one from recordsTotal and have Datatables use that number.

    Note also that I used the dom option to remove i but added my own div to display the counts.

    Kevin

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,774

    Not sure what you are doing with this one row but you could use row().data() to get the row data, append it to the thead then remove it using row().remove() as Colin suggested. This way you wouldn't need to mess with creating your own info display.

    Kevin

  • lenamtllenamtl Posts: 265Questions: 65Answers: 1

    Thanks

  • ngoctranngoctran Posts: 1Questions: 0Answers: 0

    You can get length data and add it into the language option.

    Example:

    var length_of_table = 123;

    ....DataTable({
    language: {
    "info": "Total: " + length_of_table
    }
    })

Sign In or Register to comment.