cancel
Showing results for 
Search instead for 
Did you mean: 

sap.ui.table.TreeTable with oData: Prevent leafs having an expand icon

Former Member
0 Kudos

Hi all,

I try to use sap.u.table.TreeTable to show a hierarchy provided by an Odata service. I bind the data to the treetable in my controller like this:

oTreeTable.bindRows({
 path : "/HierarchyElementSet",
 filters : oFilters,
 parameters : {	navigation : {'HierarchyElementSet' : 'ChildNodes'}}
});

I define the treetable in a xml view like this:

<t:TreeTable id="parameter1TreeTable" selectionMode="Single" enableColumnReordering="true" expandFirstLevel="true" title="test">
 <t:columns>
  <t:Column label="{i18n>ElemID}">
   <t:template><Text text="{ElemId}" /></t:template>
  </t:Column>
  <t:Column id="ElemTextId" label="{i18n>ElemText}">
   <t:template><Text text="{ElemText}" /></t:template>
  </t:Column>
 </t:columns>
</t:TreeTable>

With this configuration my treetable looks like this:

test.png

My problem is that also the leafs (SP and SW) have a plus sign indicating to be expandable - although there are no children below them:

  • How can I prevent the leafs to have the expand icon?
  • Is there also a way to change the expand icon from +/- to >?

Thanks in advance for your help.

Best regards

Dan

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member227918
Active Contributor
0 Kudos

UI5 version? its working for me for 1.28 and 1.38 UI5 versions.

I believe this is not a bug nor your code issue, its all about data structure, just verify your data once again.

Former Member
0 Kudos

I use 1.38. The URL http://[host]:[port]/sap/public/bc/ui5_ui5/ shows 1.30 to 1.38.

I think the problem is the oData service, which is set up using navigation properties (like mentioned here), instead of using annotations (like here). Now I will try to set the treeAnnotationProperties (like mentioned here). Perhaps this will work.

Former Member
0 Kudos

Now I changed from navigation property to treeAnnotationProperties:

oTreeTable.bindRows({
 path : "/HierarchyElementSet",
 filters : oFilters,
 parameters : {
  /*navigation : {
   HierarchyElementSet' : 'ChildNodes'
  },*/
  treeAnnotationProperties : {
   hierarchyLevelFor : 'HierLevel',
   hierarchyNodeFor : 'SeqNr',
   hierarchyParentNodeFor : 'ParentId',
   hierarchyDrillStateFor : 'DrillDownState'
  }
 }
});

But this breaks my Get request. Is the syntax correct or do I have to check my Odata service?

Best regards

Dan

former_member227918
Active Contributor
0 Kudos

what is the error ? share error message here

Former Member
0 Kudos

With treeAnnotationProperties set in the frontend, I had to add 'HierLevel' and 'ParentId' to the filter in the backend service.

After this I do not get an error any more. But the treeTable is empty now in the frontend, although the backend call gets one record:

<content type="application/xml">
<m:properties xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
...
<d:ParentId/>
<d:HierLevel>1</d:HierLevel>
<d:SeqNr>0</d:SeqNr>
<d:DrilldownState>expanded</d:DrilldownState>
...
</m:properties>
</content><br>

Strange. Do you know what I am doing wrong?

Former Member
0 Kudos

Do I have to remove the navigation property from my backend service, when using the treeAnnotations property?

Perhaps this causes the "no-data" problem?

As you can see in my controller I commented it out:

oTreeTable.bindRows({
				path : "/HierarchyElementSet",
				events : {
                    dataRequested: function (oEvent) { oTreeTable.setBusy(true); },
                    dataReceived: function (oEvent) { oTreeTable.setBusy(false); }
                    },
				filters : oFilters,
				parameters : {
					/*
					navigation : {
						'HierarchyElementSet' : 'ChildNodes'
					}
					*/
					countMode: 'Inline',
					treeAnnotationProperties : {
						hierarchyLevelFor : 'HierLevel',
						hierarchyNodeFor : 'SeqNr',
						hierarchyParentNodeFor : 'ParentId',
						hierarchyDrillStateFor : 'DrillDownState'
					}
				}
			});

But in my service implementation in the backend there is still a navigation property (although I am not using it):

sap-gateway-service-builder-remote-2017-05-03-13-4.png