package com.smartgwt.sample.client;


import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.ImgButton;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.VStack;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class BuiltInDS implements EntryPoint {
	private ListGrid boundList;

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		VStack vStack = new VStack();
	
		boundList = new ListGrid() {
			@Override
			protected Canvas createRecordComponent(final ListGridRecord invoice, final Integer colNum) {		
				if (colNum==4) {				
					ImgButton btn = new ImgButton();
					btn.setHeight(20); 
					btn.setWidth(20);
					
					return btn;
				}
				return null;
			}		
		};     
		
		// Set to true in order to be able to override createRecordComponent
		boundList.setShowRecordComponents(true);
		boundList.setShowRecordComponentsByCell(true);
			
		boundList.setHeight(500);
		boundList.setWidth(500);
		boundList.setCanEdit(true);


		vStack.addMember(boundList);

		boundList.setDataSource(DataSource.get("employees"));
		boundList.fetchData();
		
		vStack.draw();
	}


}
