on 05-29-2015 12:35 PM
hi all
i am developing an sapui5 application data comes from an oData requset i am putting my odata into a named json model and i ambinding this named model to the list in detail page
now i am having the list of attribute in detail page attribute tab
now user clicks on any attribute i want navigate to another page for editing for this what i did is
in detail.controller
this.getRouter().navTo("attribute",{path:slectedrecid},false); |
here i am passing the id of selected record and in attribute.controller
var jsonmodel = sap.ui.getCore().getModel("attributeJson");
this.getView().setModel(jsonmodel);
sEntityPath = "/attributes/0";
var context = {oModel: jsonmodel, sPath: sEntityPath};
oView.setBindingContext(context);
for testing ia am fixing the context path as attribute/0 and setting this model to this view and in attributes view
<f:content>
<Label text="ListNumber"/>
<Text text="{ListNumber}"/>
<Label text="Counter"/>
<Text text="{Counter}"/>
<Label text="MaintenanceLevel"/>
<Text text="{MaintenanceLevel}"/>
<Label text="AttributeProvided"/>
<Text text="{AttributeProvided}"/>
but the adata is not displayed .
thanks in advance.
Hi Kotesh,
Let's say you have Master view and Details. There is a button on Master View called "Execute". The event attached to this button is "Execute".
You need to perform 3 steps:
Master Controller Code:
handlePressExecute : function (evt) {
// Create a Model Instance and pass it with nav.to function
var GRNSummarySetModel = new sap.ui.model.json.JSONModel(); | |||
GRNSummarySetModel.setData(data); | |||
this.nav.to("GrnReportDetail", GRNSummarySetModel); |
};
Detail View. XML:
I have bind a table to this model on detail view.
<Table xmlns="sap.m" id="idItemTable" class="tableBorder" | ||||||||
---|---|---|---|---|---|---|---|---|
items="{/}" visible="true" inset="false" | ||||||||
width="100%" includeItemInSelection="false" showUnread="false" growingScrollToLoad="true" | ||||||||
noDataText="" showNoData="true" enableBusyIndicator="true" | ||||||||
modeAnimationOn="true" showSeparators="None" swipeDirection="Both" | ||||||||
backgroundDesign="Translucent" fixedLayout="false" showOverlay="false" | ||||||||
select="" swipe="both" growing="true" wrapping="true" | ||||||||
growingThreshold="100" > | ||||||||
<columns> | ||||||||
<Column xmlns="sap.m" hAlign="Center" vAlign="Middle" | ||||||||
visible="true"> | ||||||||
<Text xmlns="sap.m" visible="true" text="{i18n>GrnNo}" | ||||||||
textDirection="Inherit" wrapping="false" textAlign="Begin"> | ||||||||
</Text> | ||||||||
</Column> |
</columns> |
<items> | ||||||||
<ColumnListItem xmlns="sap.m" visible="true" type="Inactive" | ||||||||
unread="false" selected="false" vAlign="Middle" tap="" | ||||||||
detailTap="" press="" detailPress=""> | ||||||||
<Text xmlns="sap.m" visible="true" text="{Mblnr}" | ||||||||
textDirection="Inherit" wrapping="false" textAlign="Begin"> | ||||||||
</Text> | ||||||||
</ColumnListItem> | ||||||||
</items> | ||||||||
</Table> |
Detail View Controller Code:
// On init function you can retrieve this model
grndetailView = this; | ||
this.getView().addEventDelegate({ | ||
onBeforeShow: function(evt) { | ||
grndetailView.getView().getContent()[0].scrollTo(0,0); | ||
var data = grndetailView.getView().getBindingContext().getData(); | ||
var grnDetailPageModel = new sap.ui.model.json.JSONModel(); | ||
grnDetailPageModel.setData(data); | ||
grndetailView.getView().setModel(grnDetailPageModel); | ||
} | ||
}); |
},
Hope this will resolve your issue.
Thanks and regards
Abhijeet
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kotesh,
For Example:
var oTable = selfView.byId("Master--idItemTable");
oTable._aSelectedPaths // This give you selected record.
Can you please explain what is you exact requirement ?
What do you mean by static Context ?
Try Below binding:
f:content>
<Label text="ListNumber"/>
<Text text="{jsonmodel>/ListNumber}"/>
<Label text="Counter"/>
<Text text="{jsonmodel>/Counter}"/>
<Label text="MaintenanceLevel"/>
<Text text="{jsonmodel>/MaintenanceLevel}"/>
<Label text="AttributeProvided"/>
<Text text="{jsonmodel>/AttributeProvided}"/>
Hi abhijeet,
my requirement is i am able to show the named model data in list
when user clicks on list items he will navigate to another view attribute.xml
in that i am having an form here i need to bind the selected record data
for this i am doing like below
accessing the json model in attribute.controller ------> var jsonmodel = sap.ui.getCore().getModel("attributeJson").
and binding the json model to the view ------> this.getView().setModel(jsonmodel);
setting binding context to view ------>
sPath = "/attributes/0";
var context = {oModel: jsonmodel, sPath: sPath};
oView.setBindingContext(context);
so now t need render on this view but not showing.
in detail view i am having list controle like below <List items="{path: 'mainModel>/Attributes' } |
>
<items> | |||||
<ObjectListItem |
title="{mainModel>AtrDescription}"
type="Active"
press="onListItemPress"
number="{mainModel>AttributeValueProvided}" >
and in detail controller:
onListItemPress: function(oEvent) {
var sEntityPath = oEvent.getSource().oBindingContexts.mainModel.sPath;
var index = sEntityPath.lastIndexOf("/");;
var sPath =sEntityPath.substr(index+1);
this.getRouter().navTo("attribute", {
from: "detail",
entity: sPath
});
in attribute view
<Label text="AttributeName"/>
<Text text="{mainModel>AtrDescription}"/>
<Label text="AttributeValueProvided"/>
<Input value="{mainModel>AttributeValueProvided}"/>
<Label text="Description"/>
<Text text="{mainModel>Description}"/>
in attribute controller:
bindView: function(sEntityPath) { | ||
var oView = this.getView(); | ||
var | bindPath = "mainModel>/Attributes" + sEntityPath; | |
oView.bindElement(bindPath); | ||
}, |
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.