package com.smartgwt.sample.client;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridEditorContext;
import com.smartgwt.client.widgets.grid.ListGridEditorCustomizer;
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();
		boundList.setEditorCustomizer(new ListGridEditorCustomizer() {

			@Override
			public FormItem getEditor(ListGridEditorContext context) {
				if ("itemName".equals(context.getEditField().getName())) {
					return new CustomComboBoxItem();
				}
				return null;
			}

		});

		boundList.setHeight(500);
		boundList.setWidth(500);
		boundList.setCanEdit(true);

		vStack.addMember(boundList);

		boundList.setDataSource(DataSource.get("supplyItem"));
		boundList.fetchData();

		vStack.draw();
	}

}
