on 05-22-2017 9:56 PM
Sample Screenshot Image Output Code below:
function() {
//get first dropdown box selected key from first odata
var plant = sap.ui.getCore().byId("plant").getSelectedKey();
if (plant != 0) {
var sServiceUrl = "/sap/opu/odata/SAP/Z_M_EPM_BOM_SRV/";
var oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);
var filterList = [];
var i;
filterList.push(new sap.ui.model.Filter("Plant", sap.ui.model.FilterOperator.EQ, plant));
// first dropdown box selected value filter to second odata key
oModel.read("/MatCharFieldSet", {
context: null,
async: false,
filters: filterList,
urlParameters: {
"$expand": "MatCharValuesSet"
},
success: function(data) {
var res = data.results;
var content = [];
for (i = 0; i < res.length; i++) {
content.push(new sap.m.Label({
text: res[i].DescrChar,
name: res[i].FieldName
}));
var items = [];
for (var j = 0; j < res[i].MatCharValuesSet.results.length; j++) {
items.push(new sap.ui.core.Item({
text: res[i].MatCharValuesSet.results[j].FieldValue,
key: res[i].MatCharValuesSet.results[j].FieldValue
}));
}
content.push(new sap.m.Select({
items: items
}));
}
fields = new sap.ui.layout.form.SimpleForm({
editable: true,
layout: sap.ui.layout.form.SimpleFormLayout.ResponsiveGridLayout,
labelSpanL: 4,
labelSpanM: 4,
adjustLabelSpan: true,
emptySpanL: 0,
emptySpanM: 0,
columnsL: 4,
columnsM: 4,
content: content
});
fields.placeAt("fields", "only");
}
How to push all selected value item to another oDATA ?
Just a quick hack to fetch All Select Control values.
var getAllSelectInstances = $(".sapMSlt").control(); // using select control css class selector
getAllSelectInstances.forEach(function(oSelect){
var getSelectedItem = oSelect.getSelectedItem();
var getSelectedText = getSelectedItem ? getSelectedItem.getText() : null;
Console.log("Selected Value : " + getSelectedText);
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you need to first get all the selected items from the form and have to call the oModel.create("/EntitySetName", {data}, { fnSuccess, fnError} );
But i think that is only one of the many issues you are having right now.... If i am not wrong, you might be having the issue with fetching the selected item.
If yes, then give the simple form an id, then fetch the simpleform using "sap.ui.getCore().byId("simpleForm")". Now just fetch the form containers and its fields, see the sap ui5 sdk for the methods to fetch the items of simpleform and from those items, identify the select control and get the selected Item from the select control.
Now fill all that Selected data and send it to the backend using the oModel.create option.
Also, I would recomend you to use the aggregation binding in using XML view by binding the received data the simpleform.
Let me know if you have any issues..
Best Regards,
Mahesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
did u ever call create or update in odata?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
77 | |
9 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.