Skip to Content
0
May 19, 2020 at 06:46 PM

ui5 binding to dialog fragment

1912 Views

Hello,

I have created a fiori element list report based on a CDS view.

When the user selects an entry in the list and clicks on a button ‘display text’, I want to retrieve a long text from the DB and display it in a popup.

I have added a custom button on the list report.

I have implemented the method DEDUCTIONITEMTEX_GET_ENTITYin DPC_EXT

I have created the following dialog fragment:

And in the list report controller extension I have implemented the below:

	onClickTextItem: function (oEvent) {
	// GET ITEM TEXT FOR DISPLAY AND/OR UPDATE					
	// Popup to display a text item. The user will select one item.
	// By pressing button 'save' a request will be sent to the backend to modify/create the text
//get selected item of the list
	var oTable = oEvent.getSource().getParent().getParent().getTable();
	var aContext = this.extensionAPI.getSelectedContexts(oTable);
	if (aContext.length === 0 ) { sap.m.MessageBox.error("Please, select at least one item", {}); //message select at least one item
	} else {
	 //logic to get the selected item
 	…………
var mParameters  = {   BckDoc: DocNum,
                        BckItem: ItemNum };
// dialog fragment
      if (!this.byId("valTexttDialog")) {
	// load XML fragment
		this.oDialog = sap.ui.xmlfragment("xxx.rev_deductions.fragments.textItems", this);
		this.getView().addDependent(this.oDialog);
		var oModel = this.getView().getModel();
		var sPath = "/DeductionItemText";
	// access form from the fragment by its ID	
		var oForm = sap.ui.getCore().byId("EditFormId");
		oForm.setModel(oModel);
	// Get text and fill form		
		oForm.bindElement(sPath, mParameters);
	// open dialog					
                  	this.oDialog.open();
			} 
		}
	},

I have a problem to bind the elements of the simple form with the model. When I run the app I get the exception “Uncaught TypeError: Cannot read property 'indexOf' of undefined”.

I have done a similar development to display a list of items in a dialog fragment and used the bindAggregtion without any problem.

Do you have any idea how to solve the problem?

Thank you

Christophe

Attachments

fragment.png (27.8 kB)