let's say I have a code like this
Grid g = new Grid(2,2);
Label l = new Label("Hello");
g.setWidget(0,1, l);
s.setColspan(0,1,2); // there is no such method :(
So how can I set rowspan and colspan values on gwt Grid cell containing a widget?
If it's an option you can use FlexTable instead of Grid:
FlexTable flexTb= new FlexTable();
flexTb.getFlexCellFormatter().setColSpan(0, 1, 2);
flexTb.setWidget(0, 1, new Label("Hello"));
There is a not-so-simple-solution to this. It works by manipulating directly the DOM.
Grid g = new Grid(10, 5);
Element e = g.getCellFormatter().getElement(0, 0);
e.setAttribute("colspan", "5");
ArrayList<Element> toRemove = new ArrayList<Element>();
for (int x=1; x<5; x++)
toRemove.add(g.getCellFormatter().getElement(0, x));
for (Element f : toRemove)
f.removeFromParent();
It does following:
Please note, that I used to for-loops. I tried it with one single loop but some of the elements were NULL, so I tried it this way and it worked.
Thomas
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With