Saturday, November 1, 2014

Re: How to update cell with timer



On Thursday, October 23, 2014 3:22:13 PM UTC+2, Shaun Tarves wrote:
Hi -

I have created a custom cell that displays a "duration" of time between a start date and end date (public class DurationCell extends AbstractCell<Date[]>). If the end date is null, I would like the duration to "count up," like a stopwatch.

I'm stuck with how to periodically (every second) update the value of that cell. I would prefer to not have to alter the underlying data object every second, but I don't know of another approach.

Thoughts?

I think you could add a specific CSS class to an element within the cell, and add the start date in an attribute (e.g. data-start-date="1414889795967"), then in a timer get all elements with the class (using getElementsByClassName or querySelectorAll; for now you'll have to use JSNI, or Elemental, or GQuery) and process their data-start-date="" attribute to compute the duration and set their content.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment