You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Joseph Paterson <jo...@gmail.com> on 2012/06/04 03:17:24 UTC
Custom style in table view
Hi,
I'm building a TableView using apache-pivot that will have some cells that will contain a currency value (or '-' if the value is null). For visual feedback I'd like the text to appear in green if the value is zero or positive, and in red if the value is negative. I'm not quite sure where to start with this - any pointers?
Many thanks,
Joseph.
Re: Custom style in table view
Posted by Joseph Paterson <jo...@gmail.com>.
Perfect - thanks a bunch!
On Mon, Jun 4, 2012 at 1:43 PM, Roger and Beth Whitcomb <
RogerandBeth@rbwhitcomb.com> wrote:
> You probably would want a custom cell renderer. You can start with the
> Tutorial on custom TableViews here:
> http://pivot.apache.org/tutorials/table-views.custom.html
>
> What you would end up writing is a small class that subclasses
> TableViewCellRenderer or implements TableView.CellRenderer. There are
> several predefined ones you could use as examples such as
> TableViewCheckboxCellRenderer or TableViewTextAreaCellRenderer. The basic
> idea is that a renderer does what it takes to display its contents when
> asked. It can be implemented using another Pivot control (such as a Label)
> that does the heavy lifting of doing the drawing and size calculations. To
> do the coloring, you would just set styles on your Label depending on the
> value.
>
> HTH. Thanks for using Pivot and feel free to ask if you need more help.
>
> ~Roger
>
>
> On 6/3/12 6:17 PM, Joseph Paterson wrote:
>
> Hi,
>
> I'm building a TableView using apache-pivot that will have some cells
> that will contain a currency value (or '-' if the value is null). For
> visual feedback I'd like the text to appear in green if the value is zero
> or positive, and in red if the value is negative. I'm not quite sure where
> to start with this - any pointers?
>
> Many thanks,
>
> Joseph.
>
>
Re: Custom style in table view
Posted by Roger and Beth Whitcomb <Ro...@rbwhitcomb.com>.
You probably would want a custom cell renderer. You can start with the
Tutorial on custom TableViews here:
http://pivot.apache.org/tutorials/table-views.custom.html
What you would end up writing is a small class that subclasses
TableViewCellRenderer or implements TableView.CellRenderer. There are
several predefined ones you could use as examples such as
TableViewCheckboxCellRenderer or TableViewTextAreaCellRenderer. The
basic idea is that a renderer does what it takes to display its contents
when asked. It can be implemented using another Pivot control (such as
a Label) that does the heavy lifting of doing the drawing and size
calculations. To do the coloring, you would just set styles on your
Label depending on the value.
HTH. Thanks for using Pivot and feel free to ask if you need more help.
~Roger
On 6/3/12 6:17 PM, Joseph Paterson wrote:
> Hi,
>
> I'm building a TableView using apache-pivot that will have some cells
> that will contain a currency value (or '-' if the value is null). For
> visual feedback I'd like the text to appear in green if the value is
> zero or positive, and in red if the value is negative. I'm not quite
> sure where to start with this - any pointers?
>
> Many thanks,
>
> Joseph.
>