Skip to Content
0

How to change title of the page using Ui5

Oct 26, 2017 at 09:11 AM

43

avatar image

Hi,

I want to change my page title, the value will be coming from Odata service.

I am trying with, title = "{ProjectData>Project_Name}",

but unable to get any data, header shows nothing.

It would be great help, if anyone suggest me with some other options, I am pretty new in Ui5.

Thanks In Advance.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Iftah Peretz
Jan 05 at 09:47 PM
0

Hi,

Here is an option how to do it (inside the views' controller)

onInit: function() {
	var oModel = new JSONModel(...the place you get the OData from...);
	this.getView().setModel(oModel);
	oModel.attachRequestCompleted(function(oEvent) {
	        var oActiveModel = oEvent.getSource();
		document.title = oActiveModel.getProperty('/ProjectData/0/Project_Name');
			});
		    },

I am assuming the following JSON structure

"ProjectData":[{"Project_Name":"Title from OData"}]
Share
10 |10000 characters needed characters left characters exceeded