cancel
Showing results for 
Search instead for 
Did you mean: 

How to get all dropdown selected item value and push to another oData in SAPui5?

Former Member
0 Kudos
  1. All dropdown selected item value getting from first oDATA and Second oDATA.
  2. Once select or choose all dropdown value item then I want to push all selected item value to third oDATA.(Eg: After click Append button)

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 ?

Accepted Solutions (1)

Accepted Solutions (1)

former_member183518
Active Participant

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);
});
Former Member
0 Kudos

Thanks Elango. It's working fine .. how to get label text as same method?

Answers (2)

Answers (2)

maheshpalavalli
Active Contributor

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

Former Member
0 Kudos

okay . I will check and let you know

junwu
Active Contributor
0 Kudos

did u ever call create or update in odata?

Former Member
0 Kudos

No. FYI I am fresher in sapui5.

junwu
Active Contributor
0 Kudos

google please....

how to do crud in ui5