cancel
Showing results for 
Search instead for 
Did you mean: 

Binding no working when use rounting?

Former Member
0 Kudos

Hello everyone, I hope you can help me, I'm reviewing the best practices guide on sapui5, And I'm modifying a project that I already had, it runs perfectly, But when working with routing as best practices recommend, the links in my controls do not work, I think it is a config issue of the manifest.json, but I have not found the solution. Somebody could help me with an example configuration of the json.manson json model, what I currently do is:

in the view, I instantiate a json model, an extension of sap.ui.model.json.JSONModel and assign it to the core,

Then binding my table with "/ data"

var oModel = new myJSONModel; Sap.ui.getCore (). SetModel (oModel);

oTable.bindItems ("/data", new sap.m.ColumnListItem ({

cells: [ New sap.m.Text (). BindProperty ("text", "material"),

new sap.m.Text (). BindProperty ("text", "quantity"),

new sap.m.Text (). BindProperty ("text", "date"),

new sap.m.Text (). BindProperty ("text", "center"),

new sap.m.Text (). BindProperty ("text", "store"),

new sap.m.Text (). BindProperty ("text", "msg"), ] }) );

Then in the controller I call a service.

oModel2.loadDataJSONP ("http: //hostt: 8000 / sap / bc / zserve_solpejp? Sap-client = 800 /", handleSuccess, handleError, oParameters, true, 'GET', false, false , "CallBack");

function handleSuccess (oData) {

oData2 = oModel2.getData ();

var oData = sap.ui.getCore (). GetModel (). GetData ();

oData.data = jQuery.merge ([], oData2.data);

sap.ui.getCore (). GetModel (). SetData (oData, false);

defaultLightBusyDialog.close ();

}

and I do not get any error per console.

Accepted Solutions (1)

Accepted Solutions (1)

former_member365727
Active Contributor

Just a guess....

When you are not using 'manifest.json' it implies that you are not using 'Component.js' and model is set at 'sap.ui.core' which can be accessed from any view.

While using 'manifest.json'...then 'Component.js' becomes mandatory and all models are to be set at 'Component' level so that it can be accessed by the views. In this case any models set at 'sap.ui.core' will not be accessible.

Try setting the model in 'Component.js' init method and see if it works or not.

Former Member
0 Kudos

Thanks srikanth.kv4, I can already do the binding correctly. Not knowing these details caused me headaches. thank you very much.

Answers (7)

Answers (7)

Former Member
0 Kudos

srikanth.kv4 Could you help me with this please? , I've been days without the solution

Former Member
0 Kudos

The data is not shown in the table, but by testing I can see that the data if passed to var oData = sap.ui.getCore (). GetModel (). GetData ();

Former Member
0 Kudos

Component.js

Former Member
0 Kudos

manifest.json

Former Member
0 Kudos

Can you please post what you have in manifest.json?

Former Member
0 Kudos

In this case I should work with json model, not with odata model, why when I work without the manifest.json my application works normally, but when I use the manifest.son for the routing the binding no longer works?

Es obligatorio configurar el manifiesto.json para usar json model en la aplicación?

Please give me a hand.

Former Member
0 Kudos

Did you check IWFND/ERROR_LOG tcode in the backend? Also, the best way to bind a table in UI5 is the use binding in an XML view. The reason for this is performance, as it only calls for data when the table is initialized.

For example:

<Table id="idProductsTable"
		inset="false"
		items="{
			path: '/ProductCollection',
			sorter: {
				path: 'Name'
			}
		}">
		<headerToolbar>
			<Toolbar>
				<Title text="Products" level="H2"/>
			</Toolbar>
		</headerToolbar>
		<columns>
			<Column
				width="12em">
				<Text text="Product" />
			</Column>
			<Column
				minScreenWidth="Tablet"
				demandPopin="true">
				<Text text="Supplier" />
			</Column>
			<Column
				minScreenWidth="Tablet"
				demandPopin="true"
				hAlign="Right">
				<Text text="Dimensions" />
			</Column>
			<Column
				minScreenWidth="Tablet"
				demandPopin="true"
				hAlign="Center">
				<Text text="Weight" />
			</Column>
			<Column
				hAlign="Right">
				<Text text="Price" />
			</Column>
		</columns>
		<items>
			<ColumnListItem>
				<cells>
					<ObjectIdentifier
						title="{Name}"
						text="{ProductId}"/>
					<Text
						text="{SupplierName}" />
					<Text
						text="{Width} x {Depth} x {Height} {DimUnit}" />
					<ObjectNumber
						number="{WeightMeasure}"
						unit="{WeightUnit}"
						state="{
							path: 'WeightMeasure',
							formatter: 'sap.m.sample.Table.Formatter.weightState'
						}" />
					<ObjectNumber
							number="{
								parts:[{path:'Price'},{path:'CurrencyCode'}],
								type: 'sap.ui.model.type.Currency',
								formatOptions: {showMeasure: false}
							}"
							unit="{CurrencyCode}" />
				</cells>
			</ColumnListItem>
		</items>
	</Table>
Former Member
0 Kudos

I should note that this will save you the extra step of calling the oData explicitly in your controller.js logic.