Skip to Content
0

Unable to display child nodes in SAP UI5 Tree Table using JSON data

Jan 30, 2017 at 12:25 PM

459

avatar image
Former Member

Hi Everyone,I am consuming JSON data and binding to TreeTable as shown in Plunker. I am unable to show tree structure in Parent chiLd hirearchy. where everything is showing as parent nodeCould any one please help me how to get child nodes for the data shown in Plunker. if the data format is wrong for Tree Table Binding Kindly suggestThanks,Best Regards,Viswanath

10 |10000 characters needed characters left characters exceeded

Hello Viswanath,

Did you get this issue solved ? Instead of tree structure json, where you able to map it directly from flat structure in json format ?

Thanks.

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Jun Wu Jan 30, 2017 at 03:18 PM
0

you have to change your json structure, make it as tree, currently it is flat.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Jun,

when I am binding using ODATA model I am unable to bind. I am getting below attached error

So I am converting using JSON model and Binding. Could you please help in binding using ODATA annotations for the mentioned flat format data

oModel.read("/BrandSet",null,null,true,
				function Sucess(oData){
			oView.setModel(new sap.ui.model.json.JSONModel(oData), "BrandTree");
		},function error(response){
			console.log(response);
		});

capture.png (9.6 kB)
0
VIPLOVE KHUSHALANI Jan 30, 2017 at 01:45 PM
0

HI Vishwanath ,

Your Json and binding to tree table is incorrect, can you please refer this example code.

thanks

Viplove

Show 6 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Viplove,

Thanks for your response.

As my JSON structure is different from the link you shared,can I get Tree table using my current JSON structure or I should change my existing JSON structure.

Thanks,

Best Regards,

Viswanath Golakoti

0

Hi Viswanath ,

Actually the example shows in format you want the json because in JSON Tree binding json should be in the format of tree as shown in example. Check out other samples too , i think for your flat JSON you can use tree binding annotations as shown in the Basic Odata Tree Binding Example.

thanks

Viplove

1
Former Member
VIPLOVE KHUSHALANI

Hi Viplove,

Odata is implemented using OData Annotations as shown in blog Tree Table OData using second option.

But when I consume ODATA service and do binding as shown in Explored

	var sService = "/sap/opu/odata/sap/ZCRM_BRAND_ASSIGNMENT_SRV/" ;
		var oModel = new sap.ui.model.odata.v2.ODataModel(sService, { useBatch : true });

		var oView = this.getView();
	
		oView.setModel(oModel);
		if (! this._oDialogBrand) {
		      this._oDialogBrand = sap.ui.xmlfragment("fm.crm.manageaccount.fragment.BrandSelect", this);
		    } 
		
		this.getView().addDependent(this._oDialogBrand);

		this._oDialogBrand.setContentWidth("480px");
		this._oDialogBrand.open();


	

I am getting below error in console

Failed to load resource: the server responded with a status of 405 (Method Not Allowed) sap/opu/odata/sap/ZCRM_BRAND_ASSIGNMENT_SRV/

Below errors in /iwfnd/error_log

The request URL or the metadata definition is incorrect.

The specified HTTP method is not allowed for the resource identified by the Data Service Request URI


Thanks,

Best Regards,

Viswanath

capture.png (9.6 kB)
0

Hi ,

Your service desnt support batch and annotations , actually you can only use first two samples.Or create the service with annotations and batch enable.

thanks

Viplove

0
Former Member
VIPLOVE KHUSHALANI

Hi,

You mean the above errors are because of batch is not enabled? Please correct me if my understanding is wrong.

we have implemented service using annotations.

Thanks,

Viswanath

0

Actually method not allow error comes when your service doesn't support any operation like batch , POST , PUT,DELETE ,GET

Why its giving metadata definition incorrect - because odata call will first check the metadata(as this is the info or definition of the service) regrading the methods allowed.

thanks

Viplove

1