I have a data source with a "text" field that has its values separated with "|" to store user roles (to keep the database simple I have not used a separate table to link roles to users). The column's value looks like this: "|admin|management|sales|". When retrieving the data for a MultiComboBoxItem, I return the values as array from the server (thus ["admin", "management", "sales"]). I run into these two "issues":
1) Using a optionDataSource like this:
I need to filter certain roles out based on the current user. Before, I used a SelectItem (because only one role could be linked to an user) and I used this to filter out certain roles:
This seems to be impossible with MultiComboBoxItem. I therefore created a valueMap with the filtered values and this seems to work. Just checking if this is the right approach.
2) The values can be selected and saved: SmartClient sends an array, my application stores a string (with the "|" symbols), but returns the saved record using an array. Strangely, the MultiComboBoxItem now shows one button with the value "finance,sales" instead of two separate buttons. After that, saving false because unknown values are passed. Is the "text" data type incorrect? Should I return a string with comma's separated?
1) Using a optionDataSource like this:
Code:
isc.DataSource.create({ "cacheData": [ { "code": "finance", "name": "Finance" }, { "code": "readonly", "name": "Read-only" }, { "code": "management", "name": "Management" }, { "code": "system", "name": "System" }, { "code": "sales", "name": "Sales" } ], "clientOnly": true, "fields": [ { "name": "code", "primaryKey": true, "title": "Code", "type": "text" }, { "name": "name", "title": "Name", "type": "text" } ], "ID": "ROLE_ENUM" });
Code:
optionDataSource: "ROLE_ENUM", pickListCriteria: { fieldName: 'code', operator: 'inSet', value: <an array of valid roles created based on a condition> }
2) The values can be selected and saved: SmartClient sends an array, my application stores a string (with the "|" symbols), but returns the saved record using an array. Strangely, the MultiComboBoxItem now shows one button with the value "finance,sales" instead of two separate buttons. After that, saving false because unknown values are passed. Is the "text" data type incorrect? Should I return a string with comma's separated?
Comment