Skip to Content
0
Jul 06, 2020 at 02:54 PM

Display default data in Multi combo box which is in sap ui5.table using xml ui5

839 Views Last edit Jul 06, 2020 at 02:56 PM 2 rev

I am using the Multicombo box in Table control.I am trying to display the default values in Multi Combo box using the using the Json Data in xml views. I have done the data mapping in the following way. It is working if the Multicombo box is used outside the Table. but it is not displaying the default values if i use the Multi combo box in the table control. It is not displaying the default data and data list in mutlicombo box used in table. Can you please help me what is missing to fix this issue? Here is the sample code i am trying.


<sap.ui.table:Table id="notificationResultsTbl"
class="sapUiSizeCompact" alternateRowColors="true" rowHeight="60"
fixedColumnCount="2" minAutoRowCount="5" visibleRowCount="5"
 visibleRowCountMode="Fixed" showColumnVisibilityMenu="true"
selectionMode="None" rows="{"colorModel/">
<sap.ui.table:columns>
<sap.ui.table:Column width="50px" sortProperty="notifRequestID">
<sap.ui.table:label>
<Label text="Id" wrapping="true" tooltip="Notification Id" />
</sap.ui.table:label>
<sap.ui.table:template>
          <MultiComboBox items="{path:'colorModel>AvailableCarColors'}" selectedKeys="{{path:'colorModel>/KeysSelected'}" >
                                <core:Item key="{colorModel>ColorId}" text="{colorModel>Description}"/>
                            </MultiComboBox>   
                        </sap.ui.table:columns>
</sap.ui.table:template>
</sap.ui.table:Table>


Here is the Json Structure:


  var oModel = new JSONModel({
                    KeysSelected : ["Green", "Blue"],
                    AvailableCarColors: [
                                { ColorId: 'Red', Description: 'Red' },
                                { ColorId: 'Green', Description: 'Green' },
                                { ColorId: 'Blue', Description: 'Blue' },
                                { ColorId: 'Cyan', Description: 'Cyan' },
                                { ColorId: 'Magenta', Description: 'Magenta' },
                                { ColorId: 'Yellow' , Description: 'Yellow' },
                                { ColorId: 'Black', Description: 'Black' },
                      ]
                        });
                        this.getView().setModel("colorModel",oModel);
Thanks