The SelectItem dropdown list refesh problem

Hi,

I searched the forum and couldn’t get satisfactory answer. So in the hope that I can find right guidance I am posting my problem with SelectItem here. I am using SmartGWT v2.3 and IE7.


The datasource xml looks like:


<operationBinding operationType=“fetch” operationId=“fetchEmps”>
<selectClause>DISTINCT emp_id, empname</selectClause>
<tableClause>employee</tableClause>
<orderClause>empname</orderClause>
</operationBinding>


The Employee table looks like:



emp_id empname

1 abc
2 def
3 ghi


The Java code:


//declared at class level:
private SelectItem cbEmployee;
private DynamicForm form;

Inside the form load method:

cbEmployee = new SelectItem(“emp_id”, “EMPLOYEE”);
cbEmployee.setValueField(“emp_id”);
cbEmployee.setDisplayField(“empname”);
cbEmployee.setWidth(300);
cbEmployee.setPickListWidth(300);
ListGridField empNameField = new ListGridField(“empname”,“EMPLOYEE”, 300);
cbEmployee.setPickListFields(empNameField);
cbEmployee.setOptionOperationId(“fetchEmps”);
cbEmployee.setOptionDataSource(getDataSource());

form = new DynamicForm();
form.setItems(cbEmployee);


The Problem:


Initially, the selectitem shows employee names (abc,def,ghi) in cbEmployee dropdown list in dynamic form.
Suppose empname ‘abc’ was modified to ‘xyz’ using some update call somewhere in the application, then the form should
update the dropdown list to (xyz,def,ghi).
But the dropdown list is NOT refreshing although the “empMap” inside fetchData populated with the latest empname values.

I am using the following code snippet in the event handler:


final DSRequest dsrFetchEmps = new DSRequest();
dsrFetchEmps.setOperationId(“fetchEmps”);
dsrFetchEmps.setOperationType(DSOperationType.FETCH);

getDataSource().fetchData(criteria, new DSCallback() {
@Override
public void execute(DSResponse response,Object rawData, DSRequest request) {
LinkedHashMap<String, String> empMap = new LinkedHashMap<String, String>();
Record records = response.getData();
for (int i = 0; i < records.length; i++) {
Record record = records[i];
empMap.put(record.getAttribute(“emp_id”),record.getAttribute(“empname”));
}

	/*
	//Refresh cbEmployee option list in dynamic form - not working
	ListGridField empNameField = new ListGridField("empname", "EMPLOYEE", 300);
	empNameField.setValueMap(empMap);
	empNameField.setEditorValueMap(empMap);
	cbEmployee.setPickListFields(empNameField);
	*/

	cbEmployee.setValueMap(empMap);					
	cbEmployee.redraw();
	form.redraw();
}

}, dsrFetchEmps);

What I am doing wrong here?
Can you please help me refresh this selectitem pick list?

Thanks a lot!!
Chandra

There’s no need for a manual setValueMap() call - see the FAQ about grids not refreshing.