Skip to Content
-1

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

May 22, 2017 at 08:56 PM

338

avatar image
  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 ?

35236-screen.jpg (121.3 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Sakthivel Elango
May 24, 2017 at 09:00 AM
1

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);
});
Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

0
Mahesh kumar palavalli May 23, 2017 at 07:10 AM
1

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

okay . I will check and let you know

0
Jun Wu May 22, 2017 at 11:33 PM
0

did u ever call create or update in odata?

Show 2 Share
10 |10000 characters needed characters left characters exceeded

No. FYI I am fresher in sapui5.

0

google please....

how to do crud in ui5

0