my Apps: * COOL MOVIE BROWSER (sports, tv on net) here * MONEY ON THREAD (personal finance) here * HIT-BALL (cute game) here



GWT Ext - How to set background color and an image icon in the same grid-cell

Problem #1:
I must set a background color and I must renderer an image icon in the same grid-cell. How can I set this for a grid-cell?


Solution #1:
You get the solution from this posting "how to set grid-cell background"  and update it like in  the following example:

String htmlAttr = "style='background-color:yellow; background-image: url(gray_gradient.gif);background-repeat: no-repeat;'";

cellMetadata.setHtmlAttribute(htmlAttr);



Problem #2:
The method described works, but the image is not centered. How can I do it?


Solution #2:
To center the background image of your grid cell you have to add to the "style" this new attribute:
background-position, like in the following example:

String htmlAttr = "style='background-color:yellow; background-image: url(gray_gradient.gif);background-repeat: no-repeat;background-position:50%;'";

cellMetadata.setHtmlAttribute(htmlAttr);


I'm glad I could help.



Cheers!

No comments:

Post a Comment