SmartGWT 3.0
v8.2p_2012-10-11/PowerEdition Deployment
IE 8
How can I access a ImgButton component from a listGrid to update the image src of the button?
The ImgButton is created using createRecordComponent and the image needs to change when the value in a drop down list is changed.
Thanks
Todd
v8.2p_2012-10-11/PowerEdition Deployment
IE 8
How can I access a ImgButton component from a listGrid to update the image src of the button?
The ImgButton is created using createRecordComponent and the image needs to change when the value in a drop down list is changed.
Code:
listGrid = new ListGrid(){
@Override
protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {
String fieldName = this.getFieldName(colNum);
if (fieldName.equals("iconField")) {
HLayout recordCanvas = new HLayout(3);
recordCanvas.setHeight(22);
recordCanvas.setAlign(Alignment.CENTER);
ImgButton editImg = new ImgButton();
editImg.setShowDown(false);
editImg.setShowRollOver(false);
editImg.setLayoutAlign(Alignment.CENTER);
editImg.setSrc("../plus-button.gif");
editImg.setHeight(16);
editImg.setWidth(16);
editImg.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
SC.say("Icon Clicked");
}
});
recordCanvas.addMember(editImg);
return recordCanvas;
}
return null;
}
};
Code:
ListGridField dropDownList = new ListGridField("Ticket");
Criteria criteria = new Criteria();
criteria.addCriteria("code", UIConfig.CODE);
dropDownList.setOptionCriteria(criteria);
dropDownList.setOptionDataSource(DataSourceFactory.DropDownDataSource());
dropDownList.setAutoFetchDisplayMap(Boolean.TRUE);
dropDownList.setDisplayField("DESCRIPTION");
dropDownList.setValueField("CODE");
dropDownList.addChangedHandler(new ChangedHandler() {
@Override public void onChanged(ChangedEvent event) {
//Need to change the editImage button src for changed record here.
}
};
Code:
ListGridField iconField = new ListGridField("iconField");
iconField.setWidth(40);
listGrid.setFields(dropDownList ,iconField);
listGrid.setShowRecordComponents(true);
listGrid.setShowRecordComponentsByCell(true);
Todd
Comment