2017-03-23 6 views
1

GWT FlexTable에서 가장 간단한 테이블을 만드는 방법은 무엇입니까?thead와 tbody로 FlexTable을 만드는 방법

<table> 
    <thead> 
    <tr> 
     <th>Month</th> 
     <th>Savings</th> 
    </tr> 
    </thead> 
    <tbody> 
    <tr> 
     <td>January</td> 
     <td>$100</td> 
    </tr> 
    <tr> 
     <td>February</td> 
     <td>$80</td> 
    </tr> 
    </tbody> 
</table> 

theadtbody와 테이블을 만드는 방법에 대한 명확하지 FlexTable의 문서. 누구든지 도울 수 있니? 미리 감사드립니다.

답변

0

, 당신은 TableElement를 조작하여 그것을 달성 할 수있다. 꽤 낮은 수준이지만, ID는 필요한 것을 수행합니다. table.getElement(); 반환 com.google.gwt.user.client.Element 사용되지 않는 것을

FlexTable table = new FlexTable(); 

table.setText(0, 0, "January"); 
table.setText(0, 1, "$100"); 
table.setText(1, 0, "February"); 
table.setText(1, 1, "$80"); 

com.google.gwt.user.client.Element oldElement = table.getElement(); 
com.google.gwt.dom.client.Element element = (com.google.gwt.dom.client.Element) oldElement; 
TableElement tableElement = (TableElement) element; 
TableSectionElement tHead = tableElement.createTHead(); 

TableRowElement row = tHead.insertRow(0); 
row.insertCell(0).setInnerText("Month"); 
row.insertCell(1).setInnerText("Savings"); 

RootPanel.get().add(table); 

참고 : 여기에

은 예에 주어진 DOM 구조를 얻는 방법이다. 그것은 com.google.gwt.dom.client.Element을 확장하고 TableElement도 마찬가지입니다. 모든 캐스트가 완료되면 thead에 행과 셀을 추가 할 수 있습니다. 여기

는 (크롬에 GWT 2.7 테스트) 결과 :

enter image description here

0

이것은 불가능합니다. 왜 필요한가요? 당신이 유연성 FlexTable을 유지하고 thead 요소를 추가해야 할 경우

+0

글쎄, 나는 정말이 그런 식으로 작업을 수행 할 필요가 없습니다,하지만 테이블의 기본 구조 그리고 그것은 쉽게해야 GWT로 그렇게 할 수 있습니다. 아니면 내가 틀렸어? –

+0

FlexTable을 사용하는 것은 가능하지 않습니다. 하지만 실제로 원하는 것은 DataGrid 또는 CellTable입니까? – Knarf