2013-06-26 1 views

답변

0

필수 .xml 파일과 함께 클라이언트 전용 DataSource를 사용해야합니다. 샘플을 바탕으로

datasource.xml :

<List> 
    <employee> 
     <EmployeeId>4</EmployeeId> 
     <Name>Charles Madigen</Name> 
     <Job>Chief Operating Officer</Job> 
    </employee> 
    <employee> 
     <EmployeeId>192</EmployeeId> 
     <Name>Ralph Brogan</Name> 
     <Job>Mgr Software Client Supp</Job> 
    </employee> 
</List> 

장소 웹 응용 프로그램에 액세스 할 장소에 datasource.xml.

http://<host>:<port>/testApp/data/datasource.xml 

데이터 소스 클래스 :

public class EmployeeXmlDS extends DataSource { 

    public EmployeeXmlDS(String id) { 

     setRecordXPath("/List/employee"); // <== set proper XPath based on data 

     // other initialization and DataSourceField creation 

     setDataURL("data/datasource.xml"); // <== set Data URL based on above location 
     setClientOnly(true); 
    } 
} 

트리 그리드를 만듭니다

TreeGrid treeGrid = new TreeGrid(); 
// treeGrid.set* and other methods 

TreeGridField nameField = new TreeGridField("Name", 150); 
TreeGridField jobField = new TreeGridField("Job", 150); 

treeGrid.setFields(nameField, jobField); 

EmployeeXmlDS employeesDS = EmployeeXmlDS.getInstance(); 
treeGrid.setDataSource(employeesDS); // <== set the data source 

참고 : 코드 만 중요한 부분은 위에 나열됩니다.

수동으로 노드를 트리에 추가 할 수도 있습니다. 샘플 관련
http://www.smartclient.com/smartgwt/showcase/#tree_checkbox
SmartGWT 쇼케이스에서 http://www.smartclient.com/smartgwt/showcase/#tree_interaction_drag_reparent

, '소스보기'를 선택하면이있을 수 있습니다 여러 파일.
파일이 여러 개있는 경우 기본 소스 파일과 함께 탭으로 나열됩니다.