Thursday, December 2, 2010

Re: Changing ActionCell Title

Hi John,

Just wanted to say I implemented this last night, and it worked
exactly the way I wanted it to.

Thanks!

Greg

On Dec 1, 3:00 pm, John LaBanca <jlaba...@google.com> wrote:
> Everything you said sounds correct.
>
> Here is a code snippet that should work:
> ButtonCell cell = newButtonCell();
> // Create a column using the ButtonCell.
> Column<RowObject, String> column = new Column<RowObject, String>(cell) {
>   public String getValue(RowObject object) {
>     return "Show " + object.getListSize(); // Get a String from the object.
>   }};
>
> // Set a fieldupdater.
> column.setFieldUpdater(new FieldUpdater<RowObject, String>() {
>   public void update(int index, RowObject object, String value) {
>     Window.alert("You clicked " + object.toString());
>   }});
>
> myCellTable.addColumn(column);
>
> Thanks,
> John LaBanca
> jlaba...@google.com
>
> On Wed, Dec 1, 2010 at 3:33 PM, Greg Dougherty
> <dougherty.greg...@mayo.edu>wrote:
>
> > Hi John,
>
> > I'm pretty sure I'm not following you.  Here's my understanding:
>
> > I currently have an ActionCell in an IdentityColumn.  You're saying I
> > can replace the ActionCell with a ButtonCell.
> > I need to have a class implement FieldUpdater<T, C>, and pass that to
> > the IdentityColumn that holds my ButtonCell.  T is the class of my row
> > object.  C is ???
> > So you're saying that clicking on the button will fire a ValueChange
> > call that will cause my FieldUpdater to have update (int, T, C)
> > called, which can then use the T parameter to fire off my command?
>
> > Other problem: ButtonCell implements Cell<String>.  But I need to pass
> > it my row object, so that it can change its title based on non-string
> > information in the row.  (i.e. I want one button that will say "Show
> > 'x'", where x is the number of items in a list in the row object, or
> > to disable the button and put "Nothing" as the title if the list is
> > empty.  I don't see how I can do that with a ButtonCell.  Am I missing
> > something?
>
> > Thanks,
>
> > Greg
>
> > On Dec 1, 1:43 pm, John LaBanca <jlaba...@google.com> wrote:
> > > ButtonCell triggers a ValueChangeHandler when it is clicked.  Add a
> > > FieldUpdater to your Column and FieldUpdater#update() will be called.
>
> > > Thanks,
> > > John LaBanca
> > > jlaba...@google.com
>
> > > On Wed, Dec 1, 2010 at 2:29 PM, Greg Dougherty
> > > <dougherty.greg...@mayo.edu>wrote:
>
> > > > What, then, do I have to implement so that the button will fire an
> > > > action when it's clicked.  Does this require me to extend ButtonCell?
>
> > > > Thanks,
> > > > Greg
>
> > > > On Dec 1, 12:48 pm, John LaBanca <jlaba...@google.com> wrote:
> > > > > You can use a ButtonCell instead.  ButtonCell takes a String to
> > display
> > > > in
> > > > > the Button, but otherwise it looks just like ActionCell.
>
> > > > > Thanks,
> > > > > John LaBanca
> > > > > jlaba...@google.com
>
> > > > > On Wed, Dec 1, 2010 at 12:30 PM, Greg Dougherty
> > > > > <dougherty.greg...@mayo.edu>wrote:
>
> > > > > > Is it possible to change teh title of an ActionCell based on the
> > > > > > contents of the row it's in?
>
> > > > > > It looks like the answer is no, but I figured I'd check here before
> > I
> > > > > > gave up.
>
> > > > > > Greg
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "Google Web Toolkit" group.
> > > > > > To post to this group, send email to
> > > > google-web-toolkit@googlegroups.com.
> > > > > > To unsubscribe from this group, send email to
> > > > > > google-web-toolkit+unsubscribe@googlegroups.com<google-web-toolkit%2Bunsubscribe@googlegroups.com>
> > <google-web-toolkit%2Bunsubscribe@googlegroups.com<google-web-toolkit%252Bunsubscribe@googlegroups.com>
>
> > > > <google-web-toolkit%2Bunsubscribe@googlegroups.com<google-web-toolkit%252Bunsubscribe@googlegroups.com>
> > <google-web-toolkit%252Bunsubscribe@googlegroups.com<google-web-toolkit%25252Bunsubscribe@googlegroups.com>
>
> > > > > > .
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Google Web Toolkit" group.
> > > > To post to this group, send email to
> > google-web-toolkit@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > google-web-toolkit+unsubscribe@googlegroups.com<google-web-toolkit%2Bunsubscribe@googlegroups.com>
> > <google-web-toolkit%2Bunsubscribe@googlegroups.com<google-web-toolkit%252Bunsubscribe@googlegroups.com>
>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/google-web-toolkit?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > To post to this group, send email to google-web-toolkit@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-web-toolkit+unsubscribe@googlegroups.com<google-web-toolkit%2Bunsubscribe@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-web-toolkit?hl=en.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment