cancel
Showing results for 
Search instead for 
Did you mean: 

Modification an Demokit Example TreeTable

0 Kudos

Hello all,

I would like to modify the model and view for the demo sample which could be found on

https://sapui5.hana.ondemand.com/#/sample/sap.ui.table.sample.TreeTable.BasicODataTreeBinding/previe...

I would like to insert a new row.

In the controller I got the following coding, which does not work

		onInsert: function (oEvent) {
			debugger;
1			var oModel = this.getOwnerComponent().getModel();
2    			var aProperty = oModel.getProperty("/");
3    			var oProperty = {
4    				ProductId: "999",
5    				Name: "99999Name",
6    				SupplierName: "999supplierName",
7    				Category: "999"
8    			};
9    			aProperty.push(oProperty);
10    			oModel.setProperty("/", aProperty);


		}

Line 1 works fine. But I do not get an array as expected. Instead I get an object 😞

Case I get an object the line 9 will not work.

The JSON-model looks:

[
	{
		"NodeID": 1,
		"HierarchyLevel": 0,
		"Description": "1",
		"ParentNodeID": null,
		"DrillState": "expanded"
	},
	{
		"NodeID": 2,
		"HierarchyLevel": 0,
		"Description": "2",
......

My idea was now to modify the JSON-model with "Products":

{
	"Products":
		[{
		"NodeID": 1,
		"HierarchyLevel": 0,
		"Description": "1",
		"ParentNodeID": null,
		"DrillState": "expanded"
	}, {
		"NodeID": 2,
		"HierarchyLevel": 0,

Would that approach be ok?

If yes: After I made the modification in the Model.json there is no data visible any more?

What else do I have to modify?

  • component.js
  • metadata.xml
  • mockserver.js
  • view.xml

?

I would be glad if anyone could help.

Regards

Mario

Accepted Solutions (0)

Answers (0)