package com.hover.client;

 import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Button;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.layout.HLayout;
   
 public class TreeGridTest implements EntryPoint {  
   
	 ListGrid testListGrid;
	 
	 public void onModuleLoad() {  
		 testListGrid = new ListGrid();  
	     testListGrid.setWidth(200);  
	     testListGrid.setHeight(240);  
	     
	     Button b = new Button("Add");
	     b.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				testListGrid.addData(new TestListGridRecord("test"), new DSCallback() {
					
					@Override
					public void execute(DSResponse response, Object rawData, DSRequest request) {
						SC.say("Classname: " + testListGrid.getRecords()[0].getClass());
					}
				});
			}
	     });
	     
	     final ListGridField f1 = new ListGridField("title");
	     testListGrid.setFields(f1);
	     testListGrid.setDataSource(TestDS.getInstance());
	     testListGrid.setAutoFetchData(true);
	
	     HLayout layout = new HLayout(20);  
	     layout.addMember(testListGrid);  
	     layout.addMember(b);
	     layout.draw();
	 } 
 }