cancel
Showing results for 
Search instead for 
Did you mean: 

Binding Combo and DropDown box data on table load

Former Member
0 Kudos

I have a sapUI5 table that has columns using a combo box and a dropdown box control.  I'm able to bind the items to the control, select a value and save any selected items to back to the database.

PROBLEM:

I am not able to bind the database data coming in to the controls on the sapui5 table.  We are using a flyout filter and changed the bind rows; which we believe caused this issue.

any assistance would be deeply appreciated.  thanks KellySioux

VIEW:

var ddWogSizeTarget = new sap.ui.commons.ComboBox("ddMsmWogSizeTarget", {

    items: {

              path: "/WOGSIZETGT",

              template: new sap.ui.core.ListItem({ key: "{WOG_SIZE_TARGET}", text: "{RANGE_DESCR}"  })

              },

              change: function(event) {

                    oController.rowChange(this, event);

                    }

          });

ddWogSizeTarget.setModel(pps.config.ppsODataModel);

ddWogSizeTarget.bindProperty('value', 'WOG_SIZE_TARGET');

oTableMtrlSpc.addColumn

CONTROLLER:      *** here I can see the data objects populating. values are there from the database for combo box and drop down control table column, but do not populate.

    var oModel = new sap.ui.model.json.JSONModel();

    oModel.setData({modelData: data});

    gd.bindRows("/modelData");

    gd.rerender();

Accepted Solutions (0)

Answers (3)

Answers (3)

amita_jain2
Participant
0 Kudos

in case combox value entered wrongly then I am setting setValueState("Error") on that particular cell but when doing scroll in table state of cell in moving up and down & showing red border on other cells. any solution?

Former Member
0 Kudos

Ok...still not able to bind table data to the grid properly.  I did notice that the first item my drop down lists items is always selected.  Now every row in that cell is populated with the first item on the  drop down list and not the table data.

BTW the drop downs are using oDataModel binding in the view and the table grid is using JSONModel in the controller.

Any help is appreciated.....thanks

KellySioux

former_member293602
Active Participant
0 Kudos

Hi Kelly,

here is a short but complete example on a ComboBox in a Table.

I hope it helps.

Regards, Frank


var result = new sap.ui.model.json.JSONModel();
sap.ui.getCore().setModel(result);
oJsonData = {
  Category_Sales_for_1997 : [
   { CategoryName : "Beverages", CategorySales : "11.11", Currency : "EUR"},
   { CategoryName : "Something", CategorySales : "33.33", Currency : "EUR"},
   { CategoryName : "Confections", CategorySales : "22.22", Currency : "EUR"}
  ],
  Currencies : [
    { Name : "Euro",     Code : "EUR"},
    { Name : "Pound",    Code : "GBP"},
    { Name : "US Dollar",Code : "USD"}
  ]
};
result.setData(oJsonData);
// Create the column templates
var nameColumnTemplate = new sap.ui.commons.TextField({
value: "{CategoryName}"
});
var salesColumnTemplate = new sap.ui.commons.TextField({
value: "{CategorySales}"
});
var salesCurrencyTemplate = new sap.ui.commons.ComboBox({
items: {
  path: "/Currencies",
  template: new sap.ui.core.ListItem({
   key: "{Code}",
   text: "{Name}"
  })
},
value: "{Currency}"
})
var oTable = new sap.ui.table.Table({ // create Table UI
columns : [
  {label: "Name", template: nameColumnTemplate  },  
  {label: "Sales", template: salesColumnTemplate },
  {label: "Currency", template: salesCurrencyTemplate}
]
});

oTable.bindRows({path: "/Category_Sales_for_1997"} ); // bind the table rows to an array

oTable.placeAt("content"); // place Table onto UI

Former Member
0 Kudos

Hi Frank, thanks for replying.  I am able to get the drop down lists but the data will not populate on the table column on load or after I save it and re-render the table. I'm only having this issue with my embedded dropdown and combo box.  all other controls are working perfectly. 

any suggestions?