reactive-table icon indicating copy to clipboard operation
reactive-table copied to clipboard

Row Count

Open frank1340 opened this issue 9 years ago • 11 comments

Hello,

I'm struggling to pull the row count from $('.rows-per-page-count') reactively.

Is there any other way to do this and what am I doing wrong? I follow the logic for currentPage but can't quite get it working for the row count.

Thanks.

frank1340 avatar Feb 29 '16 16:02 frank1340

The value from the DOM isn't reactive, so any reactive computations won't automatically rerun when it changes. Unlike rowsPerPage or currentPage you can't change it, so I don't have it exposed as a ReactiveVar.

Since this changes when the collection or filters change, you could have a reactive computation that depends on those and checks $('.rows-per-page-count'), but I think it would be a lot of work to set up. Sorry I don't have any better ideas.

aslagle avatar Mar 03 '16 04:03 aslagle

Thank you.

I am doing that to produce a csv file so it is not too laborious, but it made me feel like a hack & Meteor novice. I wanted to ensure I was doing it properly.

frank1340 avatar Mar 03 '16 14:03 frank1340

In the same line of thinking, I cannot get the "ready" concept to work.

frank1340 avatar Mar 03 '16 15:03 frank1340

If you pass in a ReactiveVar for ready it should work to use it in a reactive computation. Maybe make sure it's initially set to false?

aslagle avatar Mar 04 '16 03:03 aslagle

Can you demonstrate as was done to test?

frank1340 avatar Mar 04 '16 17:03 frank1340

It depends on what you're trying to do with it. Somewhere in your code create a new ReactiveVar(false), and in the table settings pass that in as ready. Then you should be able to get the value of that variable in any reactive computation, such as a template helper or Tracker.autorun, and it will rerun whenever the table updates the value. I haven't tested it that much so it's possible there are problems I haven't run into. Did you try something that wasn't working?

aslagle avatar Mar 05 '16 15:03 aslagle

This is not working the way I thought it would.

var ready = new ReactiveVar(false); this.ready = ready; this.currentPage = currentPage; this.autorun(function() { Session.set('ccmReady', ready.get()); Session.set('ccmCurrentPage', currentPage.get()); });

tableSettings: function () { return { ready:Template.instance().ready, currentPage: Template.instance().currentPage,

frank1340 avatar Mar 05 '16 18:03 frank1340

How were you expecting it to work? It stays false until the table is initially loaded, but it doesn't go back to false when you change the page or the filter. In that case the table displays the previous data until the new data is available, and I thought that looked better than the table briefly disappearing, but maybe something else would be better. Is that what you meant?

aslagle avatar Mar 09 '16 01:03 aslagle

Well honestly it stays false for me now, never goes to true. Is that an error on my part?

Overall, I'm looking to make my application flow better. When someone clears the 10+ filters I have to reload the entire table, it takes 1-3 seconds. Perhaps that time can be lessened with due diligence, but some form of feedback is useful to a user each time the result set changes.

Thanks for replying.

On Tue, Mar 8, 2016 at 8:56 PM, Amy Slagle [email protected] wrote:

How were you expecting it to work? It stays false until the table is initially loaded, but it doesn't go back to false when you change the page or the filter. In that case the table displays the previous data until the new data is available, and I thought that looked better than the table briefly disappearing, but maybe something else would be better. Is that what you meant?

— Reply to this email directly or view it on GitHub https://github.com/aslagle/reactive-table/issues/366#issuecomment-194063692 .

frank1340 avatar Mar 09 '16 02:03 frank1340

ready only works if you're using ReactiveTable.publish on the server. If you're doing that and it's staying false there must be a bug somewhere (and I'm surprised the table even shows up). If you're using your own pub/sub, reactive table won't know anything about the subscription status and it won't use the ready var at all.

It might make sense to have ready be false again when the filters change, but I would have to figure out how to detect that or let you set it.

aslagle avatar Mar 09 '16 02:03 aslagle

Im certainly using the publish feature -- ill look again to make sure im not doing something stupid but it is always false.

Sent from my iPhone

On Mar 8, 2016, at 9:37 PM, Amy Slagle [email protected] wrote:

ready only works if you're using ReactiveTable.publish on the server. If you're doing that and it's staying false there must be a bug somewhere (and I'm surprised the table even shows up). If you're using your own pub/sub, reactive table won't know anything about the subscription status and it won't use the ready var at all.

It might make sense to have ready be false again when the filters change, but I would have to figure out how to detect that or let you set it.

— Reply to this email directly or view it on GitHub.

frank1340 avatar Mar 09 '16 02:03 frank1340