same DataSource for form and grid

Using SmartGWT 2.5 (Enterprise Evaluation download) - I have the HibernateSpringDMI sample/tutorial working with Oracle 11g in the back end and using annotations with my POJOs. I am using the same DataSource to bind it to both the ListGrid and the DynamicForm. My issue is that I want to show the Department column as a value in the grid (“IT” or “ACCOUNTING”), but I want the same field/property to show as a selected value w/in a dropdown/select list (a list of departments - deptno/dname). Do I need to create 2 separate datasources? Or do I handle this on the client side after the object (grid or form) has been bound?

Take a look at ListGridField.optionDataSource - to take the approach mentioned for larger datasets, see DataSourceField.valueXPath for getting the display value out of the related Hibernate entity.

Here is either a solution or a hack to the issue. In my employeeItemSpringDMI.ds.xml file, I have created the following for the department for the user/employee:

<field name=“deptno”
title=“Department”
optionDataSource=“departmentItemSpringDMI”
editorType=“select”
displayField=“dname”/>

In the my entry point html file, I load both datasources invoking the DataSourceLoader servlet (…?dataSourceLoader?dataSource=employeeItemSpringDMI,departmentItemSpringItemDMI)

When the page renders, the department value shows in the grid list as text (ACCOUNTING or OPERATIONS), and in the dynamic form the department shows up as the selected department within the select list of departments.

This is fine if you are dynamically loading the datasources upon start up. I tried this manually using the DataSource.load(“departmentItemSpringItemDMI”,… and then getting it in the execute override (DataSource.get(“departmentItemSpringItemDMI”)). I then got the ListGridField (“deptno”) and the FormField (“deptno”) and then called the .setOptionDataSource for each. When the page renders, I still get the dropdown list of departments in the dynamic form, but the department column in the list grid now shows the ID and not the name. My understanding is that DataSourceLoad servlet works the same as explicitly calling DataSource.load and the DataSource.get in the Java code.