java - GWT:how to change row font in GWT Celltable? -
i have list of fonts in array list, adding fonts cell table (gwt), complete list displaying default font only. requirement if font name "arial" name should displayed "arial" font , if font name "calibri" name should displayed "calibri" font, remaining fonts also. how can display fonts list in "combo box" "cell table" .
cells in gwt can have custom renderer. please refer sample details - tried keep simple possible:
public class sample implements entrypoint { private static final templates t = gwt.create(templates.class); public interface templates extends safehtmltemplates { @template("<span style='{0}'>{1}</span>") safehtml fontname(safestyles styles, string name); } static class font { string name; public font(string name) { this.name = name; } } class fontcell extends abstractcell<font> implements cell<font> { @override public void render(context context, font font, safehtmlbuilder sb) { sb.append(t.fontname(safestylesutils.fromtrustednameandvalue("font-family", font.name), font.name)); } } class fontcolumn extends column<font, font> { public fontcolumn() { super(new fontcell()); } @override public font getvalue(font object) { return object; } } private static list<font> fonts = arrays.aslist( new font("arial"), new font("courier new"), new font("tahoma"), new font("verdana")); public void onmoduleload() { celltable<font> celltable = new celltable<font>(); celltable.addcolumn(new fontcolumn(), "font"); new listdataprovider<font>(fonts).adddatadisplay(celltable); rootpanel.get().add(celltable); } }
Comments
Post a Comment