Skip to Content
0
Former Member
Sep 03, 2012 at 05:20 PM

Combo Box in a DataTable

118 Views

Hi guys,

I'm having trouble with dropdown boxes within DataTable (JS view). Whenever I click on the arrow icon no data is displayed. It all works okay in case items are manually added to the combo box (without context binding).

I couldn't find any obvious reason for this. Besides, if the dropdown is embedded in a MatrixLayout (as opposed to DataTable), it all works okay.

Any clue?

sap.ui.jsview("testproject.Main", {          getControllerName : function() {                    return "testproject.Main";          },          createContent : function(oController) {                    var testForm = new sap.ui.commons.layout.MatrixLayout({                              id : 'testForm',                              layoutFixed : true,                              width : '960px',                              columns : 1                    });                    var productData = [ {                              "MATNR" : "1"                    }, {                              "MATNR" : "2"                    }, ];                    var oProductModel = new sap.ui.model.json.JSONModel();                    oProductModel.setData({                              modelData : productData                    });                    var oItemTable = new sap.ui.table.DataTable();                    oItemTable.setTitle("Item Table");                    oItemTable.setVisibleRowCount(10);                    oItemTable.setExpandedVisibleRowCount(10);                    oItemTable.setFirstVisibleRow(10);                    oItemTable.setSelectionMode(sap.ui.table.SelectionMode.Multi);                    oItemTable.setEditable(true);                    var oDeviceModel = new sap.ui.model.json.JSONModel();                    oDeviceModel.setData({                              hardware : [ {                                        "device" : "PC",                                        "enabled" : true                              }, {                                        "device" : "Camera",                                        "enabled" : true                              } ]                    });                    // Create a DropdownBox                    var oDropdownBox3 = new sap.ui.commons.DropdownBox("DropdownBox3Test");                    oDropdownBox3.bindProperty("tooltip", "tooltip");                    oDropdownBox3.bindProperty("editable", "editable");                    var oItemTemplate1 = new sap.ui.core.ListItem();                    oItemTemplate1.bindProperty("text", "device");                    oItemTemplate1.bindProperty("enabled", "enabled");                    oDropdownBox3.setModel(oDeviceModel);                    oDropdownBox3.bindItems("hardware", oItemTemplate1);                    var oControl = new sap.ui.commons.TextField().bindProperty("value", "MATNR");                    oItemTable.addColumn(new sap.ui.table.Column({                              label : "Selected",                              template : oControl                    }));                    oItemTable.addColumn(new sap.ui.table.Column({                              label : "Material Code",                              template : oDropdownBox3,                    }));                    oItemTable.bindRows("modelData");                    oItemTable.setModel(oProductModel);                    testForm.createRow(oItemTable);                    return testForm;            }});