SelectItem returning DisplayValue after editSelectedData()

SmartGWT 2.4
GWT 2.1
Firefox 3.6.15
Win XP

I have a ListGrid in an upper panel for display and a DynamicForm in the lower panel for editing. When a row is selected in the ListGrid, in the onSelectionChangedHandler() I editSelectedData() from the grid. I have two SelectItems in the form which have optionDataSources and to which I apply criteria (setOptionCriteria) in the same onSelectionChangedHandler(). From the logs it is clear that the optionDataSources() automatically perform their
fetch()'s as expected and return the proper number of rows.

If I simply press the Update button, which executes a form.saveData() the update fails because the values returned from the SelectItems are the display values rather than the id values. However, if I click on each of the picker icons without changing the selections before I press the Update button the update works fine. The onChanged events of the SelectItems do fire when I click on the picker icons but they are not doing new fetches from the server.

This seems like a common use case, so I assume that I am doing something wrong. I have tried putting the editSelectedData() after I set the optionDataSource criteria but that seems to cause the picklists to display ‘No Items To Show’.

The closest example I could find in the showcase does not use setOptionCriteria rather it overrides getPickListFilterCriteria in the SelectItem. I tried this and it made no difference.

So, two questions:

  1. After calling editSelectedData(), what do I need to do to get the SelectItems to return the Values instead of DisplayValues?
  2. What actions/events tigger an automatic fetch of the optionDataSource. I had assumed that it was setOptionCriteria, but the showcase example doesn’t even use that method?

Thanks,
John

I figured I needed a small test case so I started identifying the lines that I would need to extract. Here are three critical lines I came across (they were not together in my code):

final SelectItem eventNameItem = new SelectItem("EVENT_DISPLAY_NAME", "Event");
eventNameItem.setDisplayField("EVENT_DISPLAY_NAME");
eventNameItem.setValueField("EVENT_ID");

I realized that even though I set the value and display fields properly, the name used when i created the SelectItem was the Display Field, not the Value Field. I assume that all three of these attributes are stored seperately and what must be happening is that when the editSelectedData() is called it populates the SelectItem from the ‘name’ field which is the EVENT_DISPLAY_NAME rather than the EVENT_ID.

I can see how this could easily cause the behavior that I was experiencing. I changed the name to EVENT_ID and the problem disappeared.

Thanks,
John