on 05-11-2014 9:58 AM
Hello!
I don't understand difference between subject method.
If I created XML-view, then work method this.getView().byId.
However, if I try to create JS-view, then this method does not work properly. It return unknow value. If I replace method with sap.ui.getCore().byId, then I received requested control by Id.
I understood method difference.
this.getView().byId return element by relative ID.
sap.ui.getCore().byId return element by absolute ID.
I inspected html code of created control.
If I create element with id='detail' in view "idMain1", then
1) Element definition in XML view is
<div id="idMain1--detail" class="sapMNavItem sapMPage sapMPageBgStandard sapMPageWithHeader" data-sap-ui="idMain1--detail">
i.e.: id equal view_id--element_id
2) Element definition in JS view is
<div id="detail" class="sapMNavItem sapMPage sapMPageBgStandard sapMPageWithHeader" data-sap-ui="detail">
My new question is: How to define control in JS-view, if I want its id like id in XML-view?
Best regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ivan,
not sure if I understood you correctly, but when you - for example - want an textfield with an specific ID, you can create it like this:
var tf = new sap.ui.commons.TextField("myCustomId");
In general, the first parameter of an control is always the ID. It's optional, so if you don't specifiy it, the ID will be generated by SAPUI5.
Greets,
ben
Hi Ben!
Yes, I created control with id "detail".
This is a XML view control definition
<Page
id="detail"
navButtonTap="onBack"
showNavButton="true"
title="Order" >
This is a JS view control definition
var oDetailPage = new sap.m.Page("detail",{
title: "Orders Items",
content: [oList],
headerContent: []
});
But SAPUI5 framework correct it in XML view using upper view id (idMain1) as prefix. How I can receive same result with JS view?
BR
Hi Ivan,
I'm not sure, but I don't think that you can change the way how the framework assigns the ID's.
So I guess the only way to get the same result in the JS view would be to set the desired ID "by hand".
But usually it's best practice to let the framwork handle the ID's instead of setting them manually, so you are on the save side and don't get into duplicate ID issues.
Greets,
ben
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.