I am looking to connect selectedItems, which are sourced from JsonModel in the controller, to a custom control.
Custom control
sap.ui.define([
'sap/ui/core/Control',
'sap/m/MultiComboBox',
], function (Control, MultiComboBox) {
return Control.extend('drex.control.TokenizedMultiComboBox', {
metadata: {
properties: {
selectedKeys: { type: 'string[]', defaultValue: [] }
},
aggregations: {
combo: { type: 'sap.m.MultiComboBox', multiple: false },
},
},
init: function (allItems) {
Control.prototype.init.apply(this, arguments);
},
onAfterRendering: function() {
const combo = this.getAggregation('combo');
const selectedKeys = this.getSelectedKeys();
if (selectedKeys.length) {
combo.setSelectedKeys([selectedKeys]);
}
},
renderer: function (rm, oControl) {
rm.write('<div');
rm.writeControlData(oControl);
rm.write('>');
rm.write('<div>');
rm.renderControl(oControl.getAggregation('combo'));
rm.write('</div>');
rm.write('</div>');
},
})
})
XML
<drex:TokenizedMultiComboBox
selectedKeys="{selectedItems>/disease}" />
where selectedItems>/disease
is declared in the controller:
this.getView().setModel(new JSONModel(), 'selectedItems');
The issue lies in the fact that the Multicombobox within the custom control does not display any values from selectedItems.