html - GWT wrap a table and manipulate contents programmatically -
i have formatted html table (the html text generated reporting tool) , want turn "programmable" table in gwt. need show content provided, need inspect dom, tables, , add clickhandler
's rows , cells.
i able similar images:
html html = new html(htmltext); imageelement domelement = getchildimagebytagandid(html.getelement(), "img", "blah"); image image = image.wrap(domelement); image.addclickhandler(...);
my question is: correct way tables?
i not find wrap() method <table>
, <tr>
, , <td>
elements.
note: question asked (and not answered) in comments in accepted answer here.
i unaware of easy way wrap existing table sub tr , td elements.
given constraint relying on third party tool, recommend trying build custom table parser parse existing table, build flextable, , replace existing table new flextable.
as ugly is, not sure there better way...
it may depend on how table setup, may try playing around below example go through existing table , use getnodevalue() build content of flextable....
element table = dom.getelementbyid("sometableid"); int numtopnodes = table.getchildnodes().getlength(); for(int topnode = 0; topnode < numtopnodes; topnode++){ node top = table.getchildnodes().getitem(topnode); system.out.println("top node: "+top); for(int subnode = 0; subnode < top.getchildcount(); subnode ++){ node sub = top.getchildnodes().getitem(subnode); system.out.println("sub node: "+sub); for(int rows = 0; rows < sub.getchildcount(); rows ++){ node row = sub.getchildnodes().getitem(rows); system.out.println("row: "+row); for(int cells = 0; cells < row.getchildcount(); cells++ ){ node cell = row.getchildnodes().getitem(cells); system.out.println("cell: "+cell.getnodevalue()); // use value build build new flextable } } } }
Comments
Post a Comment