SmartGWT 2.2 / FF 3.5.15
I 'm not able to display a multiple value ListGridField using a static valueMap,
although I succeed in displaying the same field in a DynamicForm.
I've defined a JSON datasource as follows :
The ListGridField displayed in the grid is defined as follows :
NB : for the moment, I don't want the field to be editable.
And the multi-select item displayed in the form :
For a user with a single role, e.g. "ROLE_USER", the valueMap is used and the value "User" is displayed,
but for a user having two roles (eg JSON string below), the value displayed in the grid is 'ROLE_USER, ROLE_ADMIN' instead of 'User, Manager'
What happens is that the valueMap is used to translate a single value into the corresponding displayValue,
but a multi-value is considered as an extra valueMap value, hence it is not translated at all and displayed as is.
Regarding the DynamicForm, single value and multiple values are displayed correctly. The only difference that I see here
is that the field in the DynamicForm is editable.
Here is the JSON string received from the server :
I 'm not able to display a multiple value ListGridField using a static valueMap,
although I succeed in displaying the same field in a DynamicForm.
I've defined a JSON datasource as follows :
Code:
RestDatasource gridDataSource = new RestDataSource(); gridDataSource.setDataFormat(DSDataFormat.JSON); DataSourceTextField username = new DataSourceTextField ("login", labelConstants.username()); DataSourceTextField authority = new DataSourceTextField ("authority", labelConstants.userAuthorities()); authority.setValueXPath("authorities/authority"); authority.setType(FieldType.ENUM); authority.setMultiple(true); LinkedHashMap<String, String> authoritiesValues = new LinkedHashMap<String, String>(2); authoritiesValues.put("ROLE_USER", "User"); authoritiesValues.put("ROLE_ADMIN", "Manager"); authority.setValueMap(authoritiesValues); gridDataSource.setFields(username, authority);
Code:
ListGridField authorityField = new ListGridField("authority");
And the multi-select item displayed in the form :
Code:
SelectItem authoritiesItem = new SelectItem("authority"); authoritiesItem.setMultipleAppearance(MultipleAppearance.PICKLIST);
but for a user having two roles (eg JSON string below), the value displayed in the grid is 'ROLE_USER, ROLE_ADMIN' instead of 'User, Manager'
What happens is that the valueMap is used to translate a single value into the corresponding displayValue,
but a multi-value is considered as an extra valueMap value, hence it is not translated at all and displayed as is.
Regarding the DynamicForm, single value and multiple values are displayed correctly. The only difference that I see here
is that the field in the DynamicForm is editable.
Here is the JSON string received from the server :
Code:
[{"authorities":[{"authority":"ROLE_USER","id":2},{"authority":"ROLE_ADMIN","id":3}],"lastlog":"2010-11-30T16:50:10","login":"user1","passwd":"*"}, {"authorities":[{"authority":"ROLE_USER","id":224}],"lastlog":null,"login":"user2","passwd":"*"}, {"authorities":[{"authority":"ROLE_USER","id":242}],"lastlog":null,"login":"user3","passwd":"*"}