package com.smartgwt.sample.client;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;

public class CustomComboBoxItem extends ComboBoxItem {

	public ListGridRecord selected;

	public CustomComboBoxItem() {
		super();

		setDisplayField("itemName");
		setAddUnknownValues(true);
		setOptionDataSource(DataSource.get("supplyItemPickList"));
		setFilterLocally(false);

		setPickListFields(new ListGridField("itemName"), new ListGridField("SKU"), new ListGridField("description"));
		setPickListWidth(300);

		addChangedHandler(new ChangedHandler() {
			@Override
			public void onChanged(ChangedEvent event) {
				// this will always fail with an exception
				selected = getSelectedRecord();
				
			}
		});
	}

}
