Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3458

Cannot get method byId("text1").getValue();

$
0
0

Hello Experts

 

I have created a custom view which gets triggered after navigating from one line item of detailed view.

After coming on page I need to get a value of a attribute which is already getting populated.

I am trying to display value in message toast on the press on button in event onButtonPress, but I am not able to get the method byID for that view even when I press code completion and if I write that explicitly I get runtime error as "Uncaught TypeError: this.byId(...).getValue is not a function".

Where I am getting missed ? Please help.

 

Below is the view code in XML and corresponding view controller code:

Please have a look at event in the controller file below. this method is not getting generated even by code completion.

 

onButtonPress: function() {  var oView = this.getView().byId("text1").getValue();       MessageToast.show(oView);       }


IssueDetails.VIEW.XML

<mvc:View xmlns:core="sap.ui.core" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc"  xmlns:sap.ui.layout.form="sap.ui.layout.form" xmlns="sap.m" controllerName="KC.controller.IssueDetail">  <Page id="__page1" showNavButton="true" title="Page" navButtonPress="onNavBack">  <content>  <Panel id="__panel0">  <customData>  <core:CustomData id="__data1" key="sap-ui-fastnavgroup" value="true" writeToDom="true"/>  </customData>  <content>  <sap.ui.layout.form:SimpleForm xmlns:sap.ui.layout.form="sap.ui.layout.form" columnsL="1" editable="false" emptySpanL="4" emptySpanM="4"  id="__form0" labelSpanL="3" labelSpanM="3" layout="ResponsiveGridLayout" minWidth="1024">  <sap.ui.layout.form:content>  <Label text="{Available}"/>  <Input width="100%" id="__input0"/>  <Text maxLines="0" text="{Bookid}" id="text1"/></sap.ui.layout.form:content>  </sap.ui.layout.form:SimpleForm>  </content>  </Panel>  <Button text="Return" width="100px" id="__button0" type="Accept" press="onButtonPress"/>  </content>  </Page></mvc:View>

IssueDetail.controller.js


sap.ui.define(["KC/controller/BaseController",  "sap/m/MessageToast"  ],  function(BaseController, MessageToast) {  "use strict";  return BaseController.extend("KC.controller.IssueDetail", {  /**  * Called when a controller is instantiated and its View controls (if available) are already created.  * Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.  * @memberOf KC.view.view.IssueDetail  */  //  onInit: function() {  var oRouter = this.getRouter();  oRouter.getRoute("issueDetail").attachMatched(this._onRouteMatched, this);  },  _onRouteMatched: function(oEvent) {  var oArgs, oView;  oArgs = oEvent.getParameter("arguments");  oView = this.getView();  oView.bindElement({  path: "/BookdetailHdrSet(" + "'" + oArgs.bookid + "'" + ")",  events: {  change: this._onBindingChange.bind(this),  dataRequested: function() {  oView.setBusy(true);  },  dataReceived: function() {  oView.setBusy(false);  }  }  });  },  _onBindingChange: function() {  // // No data for the binding  if (!this.getView().getBindingContext()) {  this.getRouter().getTargets().display("notFound");  }  },  onButtonPress: function() {  var oView = this.getView().byId("text1").getValue();  MessageToast.show(oView);  }  });  });

Viewing all articles
Browse latest Browse all 3458

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>