Skip to Content
avatar image
Former Member

Binding no working when use rounting?

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.

sin-titulo.png (98.9 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

8 Answers

  • Best Answer
    Feb 23, 2017 at 12:28 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 21, 2017 at 09:09 PM

    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>
    
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

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

  • avatar image
    Former Member
    Feb 21, 2017 at 09:20 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 21, 2017 at 10:21 PM

    manifest.json

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 21, 2017 at 09:54 PM

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 21, 2017 at 10:23 PM

    Component.js

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 21, 2017 at 10:27 PM

    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 ();

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 22, 2017 at 11:18 PM

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

    Add comment
    10|10000 characters needed characters exceeded