admin管理员组文章数量:1415460
I want to filter a table on ButtonPress an set the Table + 3 other buttons visible. My wish is to do that in the controller, but I cant seem to find a way to call a Controller Function inside the event Handler.
The Button:
var searchButton = new sap.uimons.Button({
text: 'Partner suchen',
width: "100%",
press: function(oEvent) {
var myInput = sap.ui.getCore().byId('Handler').getValue(); //$('.row input[role="textbox"]:enabled').val();
var query = oEvent.getParameter("query");
var listBinding = oTable2.getBinding();
var oFilter = new sap.ui.model.Filter ("nummer", sap.ui.model.FilterOperator.EQ, myInput);
listBinding.filter([oFilter]);
//[oController.enablen, oController]
//sap.ui.getCore().byId('vertL2').setVisible(true);
//sap.ui.getCore().byId(this.createId('anlegBut')).setEnabled(true);
//sap.ui.getCore().byId(this.createId('editBut')).setEnabled(true);
//sap.ui.getCore().byId(this.createId('submitBut')).setEnabled(true);
}
});
In my controller I have this function that I want to call:
enablen : function () {
var view = this.getView();
sap.ui.getCore().byId('vertL2').setVisible(true);
view.byId('anlegBut').setEnabled(true);
view.byId('editBut').setEnabled(true);
view.byId('submitBut').setEnabled(true);
}
But calling it inside the Event Handler of the Button seems not possible.
I want to filter a table on ButtonPress an set the Table + 3 other buttons visible. My wish is to do that in the controller, but I cant seem to find a way to call a Controller Function inside the event Handler.
The Button:
var searchButton = new sap.ui.mons.Button({
text: 'Partner suchen',
width: "100%",
press: function(oEvent) {
var myInput = sap.ui.getCore().byId('Handler').getValue(); //$('.row input[role="textbox"]:enabled').val();
var query = oEvent.getParameter("query");
var listBinding = oTable2.getBinding();
var oFilter = new sap.ui.model.Filter ("nummer", sap.ui.model.FilterOperator.EQ, myInput);
listBinding.filter([oFilter]);
//[oController.enablen, oController]
//sap.ui.getCore().byId('vertL2').setVisible(true);
//sap.ui.getCore().byId(this.createId('anlegBut')).setEnabled(true);
//sap.ui.getCore().byId(this.createId('editBut')).setEnabled(true);
//sap.ui.getCore().byId(this.createId('submitBut')).setEnabled(true);
}
});
In my controller I have this function that I want to call:
enablen : function () {
var view = this.getView();
sap.ui.getCore().byId('vertL2').setVisible(true);
view.byId('anlegBut').setEnabled(true);
view.byId('editBut').setEnabled(true);
view.byId('submitBut').setEnabled(true);
}
But calling it inside the Event Handler of the Button seems not possible.
Share Improve this question asked Apr 10, 2015 at 9:27 Osamah AldoaissOsamah Aldoaiss 3284 silver badges16 bronze badges 1-
This depends on the context the function is called in (the value of
this
). If you create the Button in thecreateContent
-function you have the parameteroController
(the default-name), that describes an instance of the view's controller – herrlock Commented Apr 10, 2015 at 9:59
1 Answer
Reset to default 3The solution to this was (after looking at the API again):
var searchButton = new sap.ui.mons.Button({
text: 'Partner suchen',
width: "100%",
press: /*[oController.enablen, oController]*/ [function(oEvent) {
var myInput = sap.ui.getCore().byId('Handler').getValue(); //$('.row input[role="textbox"]:enabled').val();
var query = oEvent.getParameter("query");
var listBinding = oTable2.getBinding();
var oFilter = new sap.ui.model.Filter ("nummer", sap.ui.model.FilterOperator.EQ, myInput);
listBinding.filter([oFilter]);
this.enablen();
}, oController]
});
本文标签: javascriptCalling Controller Function from inside a press handler in sapui5Stack Overflow
版权声明:本文标题:javascript - Calling Controller Function from inside a press handler in sapui5 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745185338a2646657.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论