package com.arplatia.example.client;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.layout.VLayout;

public class SmartGWTTest extends VLayout implements EntryPoint {
	public void onModuleLoad() {
		ListGridField id = new ListGridField("id");
		ListGridField name = new ListGridField("name");
		ListGridField count = new ListGridField("count");

		ListGrid listGrid = new ListGrid(new TestDS("testDS"));
		listGrid.setShowFilterEditor(true);
		listGrid.setWidth(250);
		listGrid.setHeight(100);
		listGrid.setFields(id, name, count);

		addMember(listGrid);

		draw();
	}

	private class TestDS extends DataSource {
		public TestDS(String idDataSource) {
			super();

			setID(idDataSource);
			setClientOnly(true);

			DataSourceIntegerField id = new DataSourceIntegerField("id", "Id");
			id.setPrimaryKey(true);
			
			DataSourceTextField name = new DataSourceTextField("name", "Name");
			
			DataSourceTextField count = new DataSourceTextField("count", "Count");

			setFields(id, name, count);
		}
	}
}
