on 03-27-2015 9:34 AM
Hi,
I was wondering if there is an event that I can use for when my sap.m.Select control is bound.
The reason is that I use the selected key to bind the rest of my view:
view.bindElement("/ThesisSet('"
+ sap.ui.getCore().byId('masterSelect')
.getSelectedKey() + "')");
I just want to bind the view with the first item of my 'ThesisSet'.
Thanks,
RW
There is an event "DataReceived" from ODataListBinding
this.byId("SELECT").getBinding("items").attachEvent("dataReceived", fnFunction, oListener);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Maksim,
binding is undefinded... So the attachEvent method doesn't work. If I'd place these lines in a setTimeout function, it works:
var binding = oTable.getBinding("items");
binding.attachEvent("dataReceived", fnFunction, oListener);
But as we agreed that's a bad solution..
It just seems like the bindItems() function takes some time in my app.
Anyways, I appreciate your help.
RW
Maksim, thanks for your reply. When I used the getSelectedKey method it still didn't work, but I found another way (the aKeys property )
sap.ui
.getCore()
.byId('masterSelect')
.bindAggregation(
"items",
{
path : "/ThesisSet",
template : seltemp,
events : {
dataReceived : function() {
view.bindElement("/"
+ this.aKeys[0]);
sap.ui
.getCore()
.byId("bijlageT")
.bindItems(
"/"
+ this.aKeys[0]
+ "/Attachments",
sap.ui
.getCore()
.byId(
'bijlagenTemplate'));
if (this.aKeys.length > 1) {
sap.ui.getCore().byId(
'masterSelect')
.setEnabled(
true);
}
}
}
});
Thanks!
RW
Hi Robbe ,the event What I know is the onchange event.
Example here: https://sapui5.netweaver.ondemand.com/sdk/explored.html#/entity/sap.m.Select/events
view.xml:
<Select id="mySelect" change="onselectchange" selectedKey="...........>
controller.js:
onselectchange: function(oEvent){
this.getView().byId("mySelect").getSelectedKey();
....
//Binding
},
This event is only triggered when the value of the select is changed. You can binding element default, and binding again when event is triggered (select another key).
Remember, if the user does not change the value of the select, the event does not launch
Bye.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks but I already knew that. I'm searching for an event when the items are loaded, not when an item is selected.
When everything is loaded the selected key will be the key of the first item, aldo I actually never selected an item...
I fixed it with the setTimeout() function, but that's only temporary. I'm searching for a clean solution.
Regards,
RW
Hi Robbe, I show you an example to do that, as you say setTimeout() is a bad solution.
sap.m.Select have a private method which is fired for update items of bind. The solution is override this method and add your own logic.
Example: JS Bin - Example
I hope that it help you
Regards,
Pau
User | Count |
---|---|
85 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.