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

Getting number of items in table in pagination template #327

Closed
OhioGuy67 opened this issue Mar 9, 2015 · 10 comments
Closed

Getting number of items in table in pagination template #327

OhioGuy67 opened this issue Mar 9, 2015 · 10 comments

Comments

@OhioGuy67
Copy link

I'm using a specialized pagination template for my table. Is there a way to get the number of items currently displayed in the table inside of the template? I didn't see any scope variables for it.

@OhioGuy67
Copy link
Author

Actually I meant the total number of items in the table after filtering.

@lorenzofox3
Copy link
Owner

#304

@OhioGuy67
Copy link
Author

My table is doing everything on the client side (i.e., doesn't make server call) so I apologize but I don't see how issue #304 answers my question.

@lorenzofox3
Copy link
Owner

sorry wrong link #261 :)

@lorenzofox3
Copy link
Owner

you can use for example

  .directive('stSummary', function () {
    return {
      restrict: 'E',
      require: '^stTable',
      template: '<div>records:{{size}}</div>',
      scope: {},
      link: function (scope, element, attr, ctrl) {
        scope.$watch(ctrl.getFilteredCollection, function  (val) {
          scope.size = (val || []).length;
        })
      }
    }
  })

to display the number of records which match

And if you don't need the search result but just the displayed collection, you can use the variable you have set with the st-table attribute (which should be the same you are using in the repeater)

@OhioGuy67
Copy link
Author

Sorry for some newbie follow-up questions (just so I'm clear). Do I add your above example directly into the smart-table.js file and then add a st-summary directive in my html? Which element do I put the directive on my in my html (the table, the tr that has the ng-repeat)? Does getFilteredCollection get called even if there is no filter on the table?

Thank you for the assistance.

This was referenced Mar 12, 2015
@spt131
Copy link

spt131 commented Jul 19, 2015

I've been unable to access the filteredCollection, could someone share an example of this working as Lorenzo's directive above?

@jbonigomes
Copy link

@spt131
Copy link

spt131 commented Aug 7, 2015

Thanks Jose, that does help. I got it working with this plunker.

On Mon, Jul 27, 2015 at 9:46 AM, Jose Gomes notifications@github.com
wrote:

Hi @spt131 https://github.com/spt131 does this help?
http://plnkr.co/edit/kKzrXKbwoMwDP1JMrvQJ?p=preview


Reply to this email directly or view it on GitHub
#327 (comment)
.

@jbonigomes
Copy link

Good stuff

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

No branches or pull requests

4 participants