Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable counting the row in pager plugin #348

Closed
johnlouie04 opened this issue Jul 1, 2013 · 9 comments
Closed

How to disable counting the row in pager plugin #348

johnlouie04 opened this issue Jul 1, 2013 · 9 comments

Comments

@johnlouie04
Copy link

is there a way to disable the count of some row in pager plugin so that it will not displaying in the pagedisplay...

@camallen
Copy link
Contributor

camallen commented Jul 2, 2013

Just remove the <span class="pagedisplay"></span> from your HTML.

@johnlouie04
Copy link
Author

What I mean is like this:

<table>
  <thead>
    <th>Table</h1>
    <th>Table</h1>
  </thead>
  <tbody>
    <tr class="count and display me"><td>count and display me</td><td>count and display me</td></tr>
    <tr class="ignore me or do not display"><td colspan="2">ignore me or do not display</td></tr>
  </tbody>
</table>

@camallen
Copy link
Contributor

camallen commented Jul 2, 2013

Sorry - I misunderstood your question.

You could look to not return these rows from the server or failing that override the code around here with custom numbers that you calculate, but this would be a hack.

I think you are trying to shoe horn functionality that isn't compatible with the library. I.e. why would you have a row that you show but do not count. And if you don't want to show it why is it in the table?

Good luck.

@TheSin-
Copy link
Collaborator

TheSin- commented Jul 2, 2013

this seems to be more of a custom thing, I somewhat do the same, so lets say you have a table and one of the cols has a number in it, a sum of something but you only want every sum that is over say 30. I first give that col a class say "coltocheck", then I add a class "countme" to that tr (row). Then I run a count on that, I have a script to update the counts which I won't post, but it's the same type of idea I think. This really wouldn't be part of tablesorter since it's a specific table usage IMHO but thought I'd share how I handle it.

        $('table.tablesorter tbody tr td.coltocheck').each(function() {
                if (parseInt($(this).html()) >= 30)
                        $(this).parent().addClass('countme');
        });

@johnlouie04
Copy link
Author

@camallen - It's ok.. What I'm planning to do is to have a show/hide for that.. something like this one

<table>
  <thead>
    <th>Data 1</th>
    <th>Data 2</th>
    <th>Data 3</th>
    <th>Data 4</th>
    <th>Data 5</th>
  </thead>
  <tbody>
    <tr>
      <td>data content</td>
      <td>data content</td>
      <td>data content</td>
      <td>data content</td>
      <td>show statistic</td>
    </tr>
    <tr>
      <td colspan="5">Show Statistics Here</td>
    </tr>
  </tbody>
</table>

so when you click the show statistic it will show the statistic data like that..

@TheSin- Thanks for the idea.. will work for that and see how is it working..

@camallen
Copy link
Contributor

camallen commented Jul 2, 2013

@johnlouie04

A quick thought, if you add the statistics row after creating the table then the row counts would be correct (until you re-evalutated the table) as they are computed on the table update / build events (when your row wouldn't be in the table).

So for instance you could tap into the table build / update event and after each event you compute your stats and insert them as their own row in JS.

Good luck!

@TheSin-
Copy link
Collaborator

TheSin- commented Jul 29, 2013

now that I think about it more, if it's just a stats row you want why not add it to tfoot instead? then it won't be counted. Only tbody gets counted.

@Mottie
Copy link
Owner

Mottie commented Sep 29, 2013

It is as @TheSin- mentioned. Just add your extra statistic row into the tfoot (see this demo).

I did find a bug that will be fixed in the next update. It causes the pager to not properly hide child rows when the removeRows option is false; and breaking when the removeRows option is true... how'd I miss that? o.O

@Mottie
Copy link
Owner

Mottie commented Oct 3, 2013

Oh I guess I misunderstood the question too... to make the pager ignore a row, just make it a child row. It does attach it to the row above it, so keep that in mind.

<tr class="tablesorter-childRow">
    <td colspan="5">Show Statistics Here</td>
</tr>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants