on 12-08-2015 6:53 PM
Hi Experts.
I was developing my first view in UI5 a while ago and I did it using JavaScript.
As soon as I was enjoying it I started to look for best practices and patterns and started to develop in XML.
My first view had two fields that were populated by two oDatas, one with months and the other with years and in Javascript I was able to filter it using some functions and populate the two field with the current month and year.
I want to know how to do it in XML.
Thanks,
Hi,
I also don´t know a way to directly do this in the XML view. I think this it is not possible.
However you can set a model in the controller:
var oModel = new sap.ui.model.json.JSONModel({currentMonth : new Date().getMonth()});
this.getView().setModel(oModel);
and then bind a field in the view to that model:
<Text text="{/currentMonth}"/>
The same you can do for the current year.
This worked for me.
Best regards,
Sebastian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sebastian. Thanks for your answer it helped me a lot but unfortunately I still have issues.
I can display in my dropdownbox the current month and year but I want to display all the others years and months too.
I have an OData with them so basically I want to display at first the current date but should be able to change it.
Thanks a lot.
do the same in your controller
it is not in the xml.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.