Here some code snippet might help..

Cell<MyQuote> qCell=new MyQuoteCell("click");//custom abstract cell defined
below.
Column<MyQuote, MyQuote> qCol=new Column<MyQuote, MyQuote>(qCell) {
                @Override
                public MyQuote getValue(MyQuote object) {

                    return object;
                }
            };


public class MyQuoteCell extends AbstractCell<MyQuote> {

    public interface MyQuoteTemplate extends SafeHtmlTemplates{
        @Template("<div class=\"style-a\">{0}</div>")
        SafeHtml aDiv(String qn);
        @Template("<div class=\"style-b\">{0}</div>")
        SafeHtml bDiv(String qn);
    }

    private static MyQuoteTemplate template=null;

    public MyQuoteCell(String... consumedEvents) {
        super(consumedEvents);
        if(template==null){
            template=GWT.create(MyQuoteTemplate.class);
        }

    }

    @Override
    *public void render(MyQuote value, Object key, SafeHtmlBuilder sb) {**
        if(value!=null){
            if("A".equals(value.getQuoteType())){
                sb.append(template.aDiv(value.getQuoteName()));
            }else if("B".equals(value.getQuoteType())){
                sb.append(template.bDiv(value.getQuoteName()));
            }else{
                //render a default one similar to above.
            }

        }

    }*

}

this is untested code. -:P


Cheers,
Subhro.

On Tue, Dec 21, 2010 at 3:09 PM, Thomas <t...@conscius.com> wrote:

> Hi,
>
> I have been searching through this forum and other places on the
> internet to find examples of how to style cells differently within a
> column - but without luck. I hope you can help me.
>
> Here is my problem:
>
> I have a CellTable showing a list of objects. A simplified example of
> this object looks like this:
>
> class MyQuote {
>    public String getQuoteName();
>    public String getQuoteType();
> }
>
> My problem is that I want to apply style A to the cell if quoteType is
> X and apply style B to the cell if quoteType is Y. How can I do that?
>
> I have tried by creating a custom column class (extends Column) and a
> custom cell class (extends ClickableTextCell) but without luck. The
> column class is aware of the MyQuote object and thereby both quoteName
> and quoteType but if I apply the styling in the column class getValue
> method - for example "<div class="A">quoteName</div>" - the HTML gets
> escaped. I have also tried to apply styling in the cells render method
> but here I have only knowledge to the value being displayed, which is
> quoteName, and not quoteType so I cannot determine the style class.
>
> Regards,
> Thomas.
>
> --
> 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-tool...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com<google-web-toolkit%2bunsubscr...@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-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to