click:function(oEvent){
/*var Val=oEvent.mParameters.value;
console.log(Val);*/
var list=this.getView().byId("LIST1");
list.getItems();
var arrlen = this.getView().byId("LIST1").getItems().length;
var arr = [];
for(var i =0;i<arrlen;i++){
var val = this.byId("LIST1").getItems()[i].getContent()[0].getValue();
arr.push(val);
}
var Totalval=arr.reduce(this.arrSum,0);
if(Totalval>this.Val)
{
sap.m.MessageToast.show("Exceed");
}
else{
sap.m.MessageToast.show("ok");
}
},
arrSum:function(total,num){
return total+ Math.round(num);
},
<core:View xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:f="sap.ui.layout.form"
controllerName="RoutingDemo.view.View2" showNavButton="true"
navButtonPress="Back" xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Page2" showNavButton="true" navButtonPress="Back">
<content>
<Input id="InputId2" width="30%" type="Number"></Input>
</content>
<List id="aaa" >
<InputListItem width="30%">
<Input id="id1" width="30%" type="Number" liveChange="setScore" />
</InputListItem>
<InputListItem width="30%">
<Input id="id2" width="30%" type="Number" liveChange="setScore" />
</InputListItem>
<InputListItem width="30%">
<Input id="id3" width="30%" type="Number" liveChange="setScore" />
</InputListItem>
<InputListItem width="30%">
<Input id="id4" width="30%" type="Number" liveChange="setScore" />
</InputListItem>
<InputListItem width="30%">
<Input id="id5" width="30%" type="Number" liveChange="setScore" />
</InputListItem>
</List>
</Page>
</core:View>
///////////////////////Controller.js
sap.ui.controller("RoutingDemo.view.View2", {
onInit: function() {
this.getRouter().attachRoutePatternMatched(this.onRouteMatched, this);
},
getRouter: function() {
return sap.ui.core.UIComponent.getRouterFor(this);
},
onRouteMatched:function(evt){
var Val=evt.getParameter('arguments').val;
this.byId("InputId2").setValue(Val);
},
Back:function(){
this.getRouter().navTo("View1");
},
setScore:function(oEvent){
/*var Val=oEvent.mParameters.value;
console.log(Val);*/
var list=this.getView().byId("aaa");
list.getItems();
// x=this.getView().byId("aaa").getItems()[0];
// x.getContent()[0].getValue();
var arrlen = this.getView().byId("aaa").getItems().length;
var arr = [];
for(var i =0;i<arrlen;i++){
console.log(this.getView().byId("aaa").getItems()[i].getContent()[0].getValue());
// x=this.getView().byId("aaa").getItems()[i];
//x.getContent()[0].getValue();
}
}
});
/*var Val=oEvent.mParameters.value;
console.log(Val);*/
var list=this.getView().byId("LIST1");
list.getItems();
var arrlen = this.getView().byId("LIST1").getItems().length;
var arr = [];
for(var i =0;i<arrlen;i++){
var val = this.byId("LIST1").getItems()[i].getContent()[0].getValue();
arr.push(val);
}
var Totalval=arr.reduce(this.arrSum,0);
if(Totalval>this.Val)
{
sap.m.MessageToast.show("Exceed");
}
else{
sap.m.MessageToast.show("ok");
}
},
arrSum:function(total,num){
return total+ Math.round(num);
},
<core:View xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:f="sap.ui.layout.form"
controllerName="RoutingDemo.view.View2" showNavButton="true"
navButtonPress="Back" xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Page2" showNavButton="true" navButtonPress="Back">
<content>
<Input id="InputId2" width="30%" type="Number"></Input>
</content>
<List id="aaa" >
<InputListItem width="30%">
<Input id="id1" width="30%" type="Number" liveChange="setScore" />
</InputListItem>
<InputListItem width="30%">
<Input id="id2" width="30%" type="Number" liveChange="setScore" />
</InputListItem>
<InputListItem width="30%">
<Input id="id3" width="30%" type="Number" liveChange="setScore" />
</InputListItem>
<InputListItem width="30%">
<Input id="id4" width="30%" type="Number" liveChange="setScore" />
</InputListItem>
<InputListItem width="30%">
<Input id="id5" width="30%" type="Number" liveChange="setScore" />
</InputListItem>
</List>
</Page>
</core:View>
///////////////////////Controller.js
sap.ui.controller("RoutingDemo.view.View2", {
onInit: function() {
this.getRouter().attachRoutePatternMatched(this.onRouteMatched, this);
},
getRouter: function() {
return sap.ui.core.UIComponent.getRouterFor(this);
},
onRouteMatched:function(evt){
var Val=evt.getParameter('arguments').val;
this.byId("InputId2").setValue(Val);
},
Back:function(){
this.getRouter().navTo("View1");
},
setScore:function(oEvent){
/*var Val=oEvent.mParameters.value;
console.log(Val);*/
var list=this.getView().byId("aaa");
list.getItems();
// x=this.getView().byId("aaa").getItems()[0];
// x.getContent()[0].getValue();
var arrlen = this.getView().byId("aaa").getItems().length;
var arr = [];
for(var i =0;i<arrlen;i++){
console.log(this.getView().byId("aaa").getItems()[i].getContent()[0].getValue());
// x=this.getView().byId("aaa").getItems()[i];
//x.getContent()[0].getValue();
}
}
});