package com.firebet.sandbox.client;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;

public class FieldTestListGrid extends ListGrid {

	public FieldTestListGrid() {
		super();
		setDataSource(DataSource.get("fieldTestDS"));
		setFields(
			new ListGridField("fieldId", "Field ID"), 
			new ListGridField("fieldName", "Field Name"), 
			new DeleteField());
	}
	
	public class DeleteField extends ListGridField {
		
		public DeleteField() {
			super("delete", "Delete?");
			setType(ListGridFieldType.ICON);
	        setCellIcon("[SKIN]actions/remove.png");
	        addRecordClickHandler(new RecordClickHandler() {

				@Override
				public void onRecordClick(RecordClickEvent event) {
					removeData(event.getRecord());	
				}
	        });
		}
	}
}
