Skip to Content

Problem binding data from view 1 to view2

Apr 25 at 08:47 PM


avatar image

Hi i'm having problems trying to bind my model data,

The problem is when i clic on one item of my table is routing to my "details" view and even my uri is changing. For example: to http://localhost:57936/PruebaKaufmann/index.html#/detail/0 if i clic on the first item but is not printing info. What could be ? (i'm using northwind's odata)

this if what should print if i clic on my first item

"ID": 0,
"Name": "Bread",
"Description": "Whole grain bread",
"ReleaseDate": "/Date(694224000000)/",
"DiscontinuedDate": null,
"Rating": 4,
"Price": "2.5",

this is my view1 (Main.xml)

	<Table id="miTabla" items="{/}" mode="SingleSelectMaster" selectionChange="onSelectionChange" >
				<Text text="ID" />
				<Text text="Nombre" />
				<Text text="Precio" />
			<ColumnListItem press="itemPress" type="Navigation">
					<ObjectIdentifier title="{Name}" titleActive="true"/>
					<Text text="{ID}" />
					<ObjectNumber number="{Price}"/>

and this is it's controller

onInit : function() {
	var sURI = "";
	var oDataModel = new ODataModel(sURI, true);
	var oModel = new JSONModel();
	var oTable = this.byId("miTabla");"/Products", {
		success: function(oData, response) {
			var oResults = oData.results;

onSelectionChange : function(oEvt) {
	var item = oEvt.getParameter("listItem");

itemPress : function(oEvent) {
	var sId = oEvent.getSource().getBindingContext().getProperty("ID");
		{Id: sId});

algunEvento : function() {"Bienvenido a Kaufmann");

and this is my second view (detail)

title="Pagina Detalles">
		<Label text="{ID}" />
		<Label text="{Name}" />
		<Label text="{Description}" />
		<Label text="{ReleaseDate}" />
		<Label text="{DiscontinuedDate}" />
		<Label text="{Rating}" />
		<Label text="{Price}" />

and the controller of above view:

onInit: function() {
	this.getOwnerComponent().getRouter().getRoute("detail").attachPatternMatched(this._onRouteMatched, this);

_onRouteMatched : function(oEvent) {
	var Id = oEvent.getParameter("arguments").Id;
	this.getView().bindElement("/Id/" + Id);

onNavBack : function() {
	var oHistory = sap.ui.core.routing.History.getInstance(),
	sPreviousHash = oHistory.getPreviousHash();
	if (sPreviousHash !== undefined) {
		// The history contains a previous entry

and for last but not least, my manifest:

"routing": {
		"config": {
				"routerClass": "sap.m.routing.Router",
				"viewType": "XML",
				"viewPath": "prueba.kaufmann.view",
				"controlId": "app",
				"controlAggregation": "pages",
				"async": true,
				"transition": "slide"
			"routes": [
					"pattern": "",
					"name": "Main",
					"target": "Main"
					"pattern": "detail/:Id:",
					"name": "detail",
					"target": "detail"
			"targets": {
				"Main": {
					"viewId": "main",
					"viewName": "Main"
				"detail": {
					"viewId": "detail",
					"viewName": "Detail"

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Jakob Marius Kjær Apr 26 at 02:55 AM

Your bind element need the entire context path, not just the ID. You can either contruct it yourself in the controller or pass it from your itemPress event

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thanks!, so i need to pass all my data as parameter with my id ?


You need to construct the entire path, not all the data. Maybe look into the tutorial for for an example.