Skip to Content

How to change title of the page using Ui5

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 05 at 09:47 PM

    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"}]
    Add comment
    10|10000 characters needed characters exceeded