Hello,
Using SmartGWT 3.0 power.
I'm pretty sure what I want to achieve is possible, but I don't know how.
I got the following SelectItem, as an editor of a ListGridField:
So, on clicking the SelectItem, a drop-down-ListGrid is displayed with records from the optiondatasource "Teacher". This will be containing first / last name combo's. Upon selection, I 'd like to display this in the SelectItem. Now It shows only the firstname. I tried, as you can see, SelectItem.setValueFormatter, to no avail (the Record r parameter doesn't seem to be updated to reflect the selected record in the drop down listgrid)
Which API (on SelectItem probably?) should I use?
Using SmartGWT 3.0 power.
I'm pretty sure what I want to achieve is possible, but I don't know how.
I got the following SelectItem, as an editor of a ListGridField:
Code:
ListGridField tea = new ListGridField("Teacher_id", teacherMessages.name_single());
SelectItem teaSel = new SelectItem();
teaSel.setOptionDataSource(DataSource
.get("Teacher"));
teaSel.setValueField("Teacher_id");
teaSel.setDisplayField("surname");
teaSel.setAllowEmptyValue(true);
teaSel.setPickListWidth(700);
ListGrid TeacherListGrid = new ListGrid();
TeacherListGrid.setShowFilterEditor(true);
TeacherListGrid.setFilterOnKeypress(true);
ListGridField t1 = new ListGridField("tussenvoegsel", teacherMessages.tussenvoegsel());
t1.setWidth(40);
teaSel.setPickListFields(
new ListGridField("firstname", teacherMessages.firstname()),
t1,
new ListGridField("surname", teacherMessages.surname()),
new ListGridField("companyName", teacherMessages.companyName())
);
teaSel.setPickListProperties(TeacherListGrid);
teaSel.setValueFormatter(new FormItemValueFormatter(){
public String formatValue(Object value, Record r,
DynamicForm form, FormItem item) {
Object v = value;
String f = r.getAttribute("firstname")==null ? "" : r.getAttribute("firstname");
String t = r.getAttribute("tussenvoegsel")==null ? "" : r.getAttribute("tussenvoegsel");
String s = r.getAttribute("surname")==null ? "" : r.getAttribute("surname");
if(r.getAttribute("surname") == null || "".equals(r.getAttribute("surname"))) {
return r.getAttribute("companyName");
}
else {
return f+t+s;
}
}
});
tea.setEditorType(teaSel);
tea.setDisplayField("surname");
Which API (on SelectItem probably?) should I use?
Comment