Hiding Columns in shared Datamodel

Hi,
We are evaluating SmartGWT to migrate a large struts/jboss project to SmartGWT. At the outset let me say that, it looks very very impressive and exciting.

If you look at the ‘Pattern Reuse’ example, you will notice that the Grid has too many columns and most of them are not readable. A good solution would be to display say 4 columns in the grid, but all fields in the dynamic form. However since the Grid and the Dynamic form share the same Data source, hiding some of the fields in the data source is not a good solution.(It hides it in both places)

I tried the following:

grid.setAutoFetchData(true);
ListGridField[] gridFields=grid.getFields();

However this returns an array of size 0.

Then we tried:
  	ListGridField hideMsgField=grid.getField(4);
       	if (hideMsgField !=null)
       		hideMsgField.setHidden(true);

This also does not work.

Then I tried:

grid.setAutoFetchData(false);
grid.fetchData();

but this results in an exception.

Any solution will be greatly appreciated.

Thanks
Ganesh

Try ListGridField.setShowIfCondition(ListGridFieldIfFunction)

The users’ ListGridFieldIfFunction implementation is evaluated to conditionally determine whether this field should be displayed. Evaluated on initial draw, then reevaluated on explicit calls to listGrid.refreshFields() or listGrid.setFields().

See also DataSourceField.setDetail(), which makes some fields appear by default only in forms and detailViewers, not in grids and trees.