on 04-07-2017 8:46 AM
Hi All,
i am developing a test split App application , where i am unable to bind data to Form.
below is my code for controller .
onInit: function() { oModel = new sap.ui.model.json.JSONModel("http://services.odata.org/V3/northwind/northwind.svc/Customers?$format=json"); sap.ui.getCore().setModel(oModel,"model1"); },
onListItemPress:function(oEvent){ debugger; var data = oModel.getData().value; str = oEvent.getSource().getId(); var id = str.slice(-2); id = Math.abs(id); jSonModel = new sap.ui.model.json.JSONModel(data[id]); sap.ui.getCore().setModel(jSonModel,"selModel"); this.getView().byId("form").setModel("selModel"); }
and Below is my Code for View .
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns:f="sap.ui.layout.form" xmlns="sap.m" controllerName="splitapp.Main" xmlns:html="http://www.w3.org/1999/xhtml"> <Page title="Title"> <content> <SplitApp xmlns="sap.m" id="id" busy="false" homeIcon="" initialDetail="detail" initialMaster="master"> <tooltip></tooltip> <!-- sap.ui.core.TooltipBase --> <dependents></dependents> <!-- sap.ui.core.Control, since 1.19 --> <masterPages> <Page id="master" title="Master Page"> <content> <List xmlns="sap.m" id="list" items="{model1>/value}" headerText="Products" itemPress="onListItemPress" type="Active"> <items> <!-- sap.m.ListItemBase --> <ObjectListItem xmlns="sap.m" id="objList" type="Active" press="onListItemPress" title="{model1>CustomerID}"> <firstStatus> <ObjectStatus text="{model1>ContactName}" /> </firstStatus> <attributes> <!-- sap.m.ObjectAttribute --> <ObjectAttribute xmlns="sap.m" text="{model1>CompanyName}"> </ObjectAttribute> </attributes> </ObjectListItem> </items> </List> </content> </Page> </masterPages> <!-- sap.ui.core.Control --> <detailPages> <Page id="detail" title="Detail Page"> <content> <f:SimpleForm id="form" layout="ResponsiveGridLayout" minWidth="1024" columnsM="2" columnsL="2" labelSpanM="4" labelSpanL="4" editable="true"> <f:content> <core:Title text="Some Sample Data" /> <Label text="Customer name" /> <Text text="{selModel>CompanyName}" /> <Label text="Customer Number" /> <Text text="111000" /> <core:Title text="" /> <Label text="Country" /> <Text text="Germany" /> </f:content> </f:SimpleForm> </content> </Page> </detailPages> <!-- sap.ui.core.Control --> </SplitApp> </content> </Page> </core:View>
i am unable to bind Data i am trying to display selected list item value in form , but its not displaying even though i did binding properly.
please suggest.
Thanks
Ashish
i think you need to learn more about UI5, this is not the way to achieve this,
have a look more on concept of ui5 and routing, and try to do it in below ways,
master controller:
onListItemPress: function(oEvent) {
this._oRouter.navTo("detail", {
entity: oEvent.getSource().getBindingContext().getPath().substr(1)
});
}
detail controller:
onInit,
onInit: function() {
this._oComponent = this.getOwnerComponent();
this._oRouter = this._oComponent.getRouter();
this._oModel = //get your model
this._oRouter.attachRoutePatternMatched(this._onRoutePatternMatched, this);
},
_onRoutePatternMatched
_onRoutePatternMatched: function(oEvent) {
if (oEvent.getParameter("name") !== "detail") {
return;
}
this._sItemPath = "/" + oEvent.getParameters().arguments.entity;
// bind detail view
this.getView().bindElement({
path: this._sItemPath
});
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
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.