How can I indicate what row to count

How can I indicate what row to count

mmendoza25mmendoza25 Posts: 3Questions: 1Answers: 0

"Showing ## to ## of ##"
For stylish purposes on my table I added some blank rows. How can I tell to Datatables not to count this rows?
On other words, how can I mark a td row to be counted or not?

Answers

  • mmendoza25mmendoza25 Posts: 3Questions: 1Answers: 0

    correction: tr row. How can I mark a tr row to be counted or not

  • kthorngrenkthorngren Posts: 21,325Questions: 26Answers: 4,949

    There isn't an option to count or not count rows that Datatables knows about. Not sure how you are adding blank rows. See if Colin's example in this thread helps. It adds empty rows but Datatables doesn't know about them.

    If this doesn't help please provide a test case showing what you are doing so we can offer suggestions.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • mmendoza25mmendoza25 Posts: 3Questions: 1Answers: 0

    Hello Kevin,
    This is my example live.datatables.net/kudiligi/1/

    It says "showing 1 to 25 of 25", but the real count that I want to show is "Showing 1 to 11 of 11", as 11 are the detail records (data start at the column "Lin").

    If you search for the word "roberto", it will show "Showing 1 to 4 of 4 entries (filtered from 25 total entries)", but I want to show "Showing 1 to 2 of 2 (filtered from 11 total entries).

    I don't know if I can "mark" somehow the TR row that contain the data detail to tell datatable that row should be counted,

    What do you think?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    DataTables treats each <tr> as a row, so there are 25 of those in your table. You could consider grouping using child rows, or perhaps RowGroup,

    Colin

  • kthorngrenkthorngren Posts: 21,325Questions: 26Answers: 4,949

    Another option is to use infoCallback. You can add a classname to the rows that you want to count. Use that as a selector for the -api rows()API. Use the-type selector-modifierof{search: 'applied'}` to get the count of filtered rows with that class. See this updated example:
    http://live.datatables.net/kudiligi/2/edit

    I added the class dt-count to two of Roberto's rows and one other row. You can add to the remaining rows if you want. The total number of rows dt-count rows is 3 and when searching for Roberto the total filtered is 2. You can apply those totals to the information element.

    Kevin

Sign In or Register to comment.