Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

SelectItem bound to DataSourceField multipleStorage="json", how does it work?

$
0
0
Hello,
using SmartClient Version: v9.1p_2014-03-23/Pro Deployment (built 2014-03-23)

Following scenario:
User management, user can have several user roles.
List of user roles is stored in a SimpleType value map.
User mgmt UI should show a list of user roles, where the roles of the respective user are already pre-selected.

Code:

UserRoles SimpleType:
<SimpleType name="MyUserRoles" inheritsFrom="text" >
        <valueMap>
                <value ID="admin">Administrator</value>
                <value ID="product_mgr">Product Manager</value>               
                <value ID="edi">Edi Manager</value>
                ...
        </valueMap>
</SimpleType>

DataSource:
<DataSource ID="MyUser" ...
  <fields>
    <field name="UserRoles" type="MyUserRoles" multiple="true" multipleStorage="json"/>
    ... more fields ....
  </fields>
</DataSource>

UI:
<SelectItem multiple="true" multipleAppearance="grid"><name>UserRoles</name></SelectItem>

When user data is saved and fetched, I can see in the developer console (and in the underlying JSON DB) the proper JSON UserRoles array as such:
UserRoles:[
"admin",
"product_mgr"
]
It is send as such to the server for save operations and also the Raw Response in the dev console for fetch operations shows the proper JSON array.

However, the SelectItem in the form does not show the user roles (here "admin" and "product_mgr") as pre-selected.

Debuggin further into FormItem.setValue(), the value does not arrive as array of the two values but as
["admin,product_mgr"].
So on client side, event though the data arrives as JSON array, the two separate array values are combined into one comma separated string ["admin,product_mgr"] in a later step.

Did I misconfigured something?
Can you give me a pointer as to where this transformation from [ "admin", "product_mgr"] to ["admin,product_mgr"] might happen.

That said, using multipleStorage="json" is on purpose, since the value is stored in a JSON DB and it arrives correctly there as well as it is also delivered correctly to the browser upon fetch.

Thank you,
Daniel

Viewing all articles
Browse latest Browse all 4756

Trending Articles