Skip to Content

Passing data between views

Hi

In manifest.json i have defines a Model:

			"transModel": {
				"type": "sap.ui.model.json.JSONModel",
				"settings": {},
				"preload": true

In main view i have bound an DateTimePicker to this model:

		        <DateTimePicker id="DateTimeFr" value="{transModel>/DateTimeFr}" displayFormat="short" change="handleTimePicker" minutesStep="15" width="20%"/>	

Now i go to detail view and want to pass the value from Main to detail, so i do like this:

                <DateTimePicker id="DateTimeFr" displayFormat="short" change="handleChange" minutesStep="15" editable="false" value="{transModel>/DateTimeFr}" />	

But in detail View data is empty. What am i missing in order to pass the value from Main to Detail?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jul 22, 2020 at 06:18 AM

    Hi Jakob,

    I hope you are using SAP Fiori template because there's already an appView model for that scenario. Check the App.controller.js, the view model for that lives at the app level and can be used to share data between views.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 22, 2020 at 11:55 AM

    Hi Jakob,

    Please try with setting the model into your main and detail view in the init method with below code:

    this.getView().setModel(this.getOwnerComponent().getModel("transModel"));

    Thanks

    Prashil

    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.