Skip to Content

Unable to access the model after onInit

  1. I have a model in component.js. I am displaying the data in a view in 'editable input fields' from that model. That model is only called in onInit(). So when I am erasing some field in the input and then navigating back and coming again on the screen, the data is not coming on that screen. I have fetched the data in XML. You can also see : StackOverflow link


	onInit: function () {
			this.router = sap.ui.core.UIComponent.getRouterFor(this);

			this.detailModel = sap.ui.getCore().getModel("detailModel");
			this.getView().setModel(this.detailModel, "detailModel");
			this.router.attachRoutePatternMatched(this._handleRouteMatched, this);

		_handleRouteMatched: function (evt) {
			if (evt.getParameter("name") !== "CloneTravelRequest") {
				var that = this;

			//fetching Train Names
				url: "/Non_sap_create_requests/odata/TravelPrpTrainDetails",
				method: "GET",
				dataType: "json",
				success: function (data) {
					that.getView().getModel("Model").setProperty("/TravelPrpTrainDetails", data.value);
					var tempModel = that.getView().getModel("detailModel");
					var train = tempModel.getData().TrainName;
					var trainKey = formatter.pickTrainKeyFromModel(data.value, train);
					var nameofPass = tempModel.getData().NameOfPsngr;
					if (nameofPass === "" || nameofPass === null) {
				error: function (err) {
			var fdate = new Date();
			this.getView().byId("date").setDateValue(new Date());
		//	this.onBeforeRendering();
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

0 Answers