$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: false, vro: false, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
0

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

Apr 26, 2017 at 02:37 PM

133

avatar image
D B

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

test.png (1.6 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Akhilesh Upadhyay Apr 26, 2017 at 02:54 PM
0

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.

Show 5 Share
10 |10000 characters needed characters left characters exceeded

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.

0

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

0

what is the error ? share error message here

0

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?

0

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

0