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]
});