Hello,
Using GWT 2.4 and Smart GWT 3.0. Most fun!
So I want to have a drop down that has formatted items, and I can get the record(s) of the item selected in the picklist that is the dropdown. I have the button click working fine, and the navigation with the keyboard. But when the enter key is clicked I can get the "enter" key, but can't seem to get the item from the pick list that was last selected. I have tried a few things.
here is my current code. Any ideas?
Evan
cbSearchOn = new ComboBoxItem();
cbSearchOn.setDisplayField("entvalue");
cbSearchOn.setSortField("entvalue");
cbSearchOn.setValueField("entvalue");
DataSource ds = DataSource.get("ravisearchon");
cbSearchOn.setOptionDataSource(ds);
// general settings
cbSearchOn.setHeight(28);
cbSearchOn.setWidth(450);
// comboBoxItemDiseases.setAnimationTime(3);
cbSearchOn.setCompleteOnTab(true);
// cbItem.setShowPickerIcon(true);
// TODO: tool tip on combo box does not format so well
cbSearchOn.setTooltip("<nobr>Start typing to reveal matches for your search.</nobr>");
// title to the left of combo box
cbSearchOn.setTitle("");
// initialize and fetch when the UI loads up
cbSearchOn.setAutoFetchData(true);
KeyUpHandler handler = new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent event) {
String strKeyName = event.getKeyName();
FormItem fi = event.getItem();
bindCurrentSearchOn(fi.getSelectedRecord());
if (strKeyName.equals("Enter")) {
fireEventsSearchOnResultsPage();
}
}
};
cbSearchOn.addKeyUpHandler(handler);
ListGridField entvalue = new ListGridField("entvalue");
entvalue.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
return record.getAttribute("entvalue") + getFieldType(record.getAttributeAsInt("entfieldskey")) ;
}
});
// The full record type is only "defined" when they select the item in the pick list
// It does not exist in the "box", only the value does at that point
CellClickHandler cellclickhandler = new CellClickHandler() {
@Override
public void onCellClick(CellClickEvent event) {
bindCurrentSearchOn(event.getRecord());
}
};
ListGrid pickListProperties = new ListGrid();
pickListProperties.addCellClickHandler(cellclickhandler);
KeyPressHandler keypresshandler = new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
String strKeyName = event.getKeyName();
if (strKeyName.equals("Enter")) {
// bindCurrentSearchOn(fi.getSelectedRecord());
}
}
};
pickListProperties.addKeyPressHandler((com.smartgwt.client.widgets.events.KeyPressHandler) keypresshandler);
cbSearchOn.setPickListProperties(pickListProperties);
// cbSearchOn.setPickListBaseStyle("");
cbSearchOn.setAnimatePickList(true);
cbSearchOn.setPickListFields(entvalue);
Using GWT 2.4 and Smart GWT 3.0. Most fun!
So I want to have a drop down that has formatted items, and I can get the record(s) of the item selected in the picklist that is the dropdown. I have the button click working fine, and the navigation with the keyboard. But when the enter key is clicked I can get the "enter" key, but can't seem to get the item from the pick list that was last selected. I have tried a few things.
here is my current code. Any ideas?
Evan
cbSearchOn = new ComboBoxItem();
cbSearchOn.setDisplayField("entvalue");
cbSearchOn.setSortField("entvalue");
cbSearchOn.setValueField("entvalue");
DataSource ds = DataSource.get("ravisearchon");
cbSearchOn.setOptionDataSource(ds);
// general settings
cbSearchOn.setHeight(28);
cbSearchOn.setWidth(450);
// comboBoxItemDiseases.setAnimationTime(3);
cbSearchOn.setCompleteOnTab(true);
// cbItem.setShowPickerIcon(true);
// TODO: tool tip on combo box does not format so well
cbSearchOn.setTooltip("<nobr>Start typing to reveal matches for your search.</nobr>");
// title to the left of combo box
cbSearchOn.setTitle("");
// initialize and fetch when the UI loads up
cbSearchOn.setAutoFetchData(true);
KeyUpHandler handler = new KeyUpHandler() {
@Override
public void onKeyUp(KeyUpEvent event) {
String strKeyName = event.getKeyName();
FormItem fi = event.getItem();
bindCurrentSearchOn(fi.getSelectedRecord());
if (strKeyName.equals("Enter")) {
fireEventsSearchOnResultsPage();
}
}
};
cbSearchOn.addKeyUpHandler(handler);
ListGridField entvalue = new ListGridField("entvalue");
entvalue.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
return record.getAttribute("entvalue") + getFieldType(record.getAttributeAsInt("entfieldskey")) ;
}
});
// The full record type is only "defined" when they select the item in the pick list
// It does not exist in the "box", only the value does at that point
CellClickHandler cellclickhandler = new CellClickHandler() {
@Override
public void onCellClick(CellClickEvent event) {
bindCurrentSearchOn(event.getRecord());
}
};
ListGrid pickListProperties = new ListGrid();
pickListProperties.addCellClickHandler(cellclickhandler);
KeyPressHandler keypresshandler = new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
String strKeyName = event.getKeyName();
if (strKeyName.equals("Enter")) {
// bindCurrentSearchOn(fi.getSelectedRecord());
}
}
};
pickListProperties.addKeyPressHandler((com.smartgwt.client.widgets.events.KeyPressHandler) keypresshandler);
cbSearchOn.setPickListProperties(pickListProperties);
// cbSearchOn.setPickListBaseStyle("");
cbSearchOn.setAnimatePickList(true);
cbSearchOn.setPickListFields(entvalue);
Comment