Skip to Content

aggregation binding dialog

Hi all,

on

https://stackoverflow.com/questions/48310621/bind-selected-item-to-dialog

with a link to Plunker

https://plnkr.co/edit/MPHT17Hf4xNj3ZuuNXMd?p=preview

is an issue which was already solved. Unfortunatelly the complete solution is not there.

Could anybody please show me how to modify the code in the controller so that the solution works fine and the data is displayed in the popUp

Thanks

Regards

Mario

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Feb 13, 2019 at 06:22 PM

    Hi Mario Müller

    You are checking the link from the question which is incorrectly code. You should check the answer below which has a link that works. Anyway, I did a small modification for the original code posted by OP and it works, check below:

    sap.ui.define([
    	"sap/ui/core/mvc/Controller",
    	"sap/m/MessageToast",
    	"sap/ui/model/json/JSONModel"
    ], function (Controller, MessageToast, JSONModel) {
    	"use strict";
    
    
    	return Controller.extend("sap.ui.demo.wt.App", {
    
    
    		onInit : function () {
    		  var me = this;
    		  
    			// set data model on view
    			var oData = {
    			  rows: [
    		  	  { sectionId: '00001000', costId: '1L' },
    		  	  { sectionId: '00002000', costId: '2' }
    			  ]
    			};
    			
    			var oModel = new JSONModel(oData);
    			me.getView().setModel(oModel, 'list');
    			
    
    
    		},
    		
    		onItemPress: function(evt) {
    		  var me = this;
    		  var view = me.getView();
    		  
    		  var item = evt.getSource().getBindingContext('list').getObject();
    		  
    		  var dlg = new sap.m.Dialog({
    		    title: 'Edit Item',
    		    type: 'Message',
    		    content: [
    		      new sap.m.VBox({
    		        items: [
    		          new sap.m.Label({ text: 'Section' }),
      		          new sap.m.Input({ value: '{detailItem>/sectionId}' }),
    		          new sap.m.Label({ text: 'Cost' }),
    		          new sap.m.Input({ value: '{detailItem>/costId}' })
    		        ]
    		      })
    		    ],
    		    beginButton: new sap.m.Button({
    		      text: 'Ok',
    		      press: function() {
    		        dlg.close();
    		      }
    		    }),
    		    endButton: new sap.m.Button({
    		      text: 'Cancel',
    		      press: function() {
    		        dlg.close();
    		      }
    		    }),
    		    afterClose: function() {
    		      dlg.destroy();
    		    }
    		  }).open();
    			var dModel = new JSONModel(item);
    			dlg.setModel(dModel, 'detailItem');
    		}
    	});
    
    
    });
    

    BR,

    Mahesh

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.