Using SelectItem with DataSource

Hi,

When a DataSource is defined the DynamicForm can ‘guess’ the field definitions and draw the appropriate edit fields. This stops unfortunately when the method DynamicForm.setFields is called, then I need to add all fields manually. However, I need this method to add a SelectItem to the form that reads its data from a DataSource component because the datasource and valuefield property needs to be set. Is there a method to define the ‘child’-datasource in the master datasource?

Also, I noticed when the form fields are updated with DynamicForm.editSelectedData the SelectItem gets the correct text value but when the list is show the value is not selected. Is this SmartClients behaviour or a bug?

Regards,
Chris

Hi Chris,

You may want useAllDataSourceFields, which allows you to overlay field definitions on top of the fields from the DataSource, but still use all fields from the DataSource except those you explicitly exclude.

Didn’t understand the second question.

To explain the second question/remark. I created datasource containing a field which does a value lookup in another datasource. On the DynamicForm I placed a SelectItem to allow the user selecting a description instead of ID.
When calling editSelectData after a row selection in a grid all form fields are updated, but when the SelectItem is dropped down the correct value is not selected.

This is the SelectItem definition:

SelectItem  manufacturer = new SelectItem();
manufacturer.setName("manufacturer");
manufacturer.setOptionDataSource(ManufacturerDataSource.getInstance());
manufacturer.setValueField("id");
manufacturer.setDisplayField("name");

// and when a row selection is done
grid.addRecordClickHandler(new RecordClickHandler() {  
  public void onRecordClick(RecordClickEvent event) {  
    form.reset();  
    form.editSelectedData(grid);  
  }  
});

After the click the correct name is displayed in the manufacturer selectItem, but when the list is shown the first item is selected instead of the name in the box.

Chris

Hi Chris,
Thanks for the clarification. This is a bug in SmartClient - the item should be selected from the drop down list when it is first shown. We’ve now resolved this in our internal code base so the fix will be present in our next release.

Thanks
Isomorphic Software