Skip to Content
0
Nov 08, 2018 at 10:24 AM

Press Link on Breadcrumbs Navigation

652 Views

Hi, I have created a simple tree with breadcrumbs navigation. What I want is to create the function for pressing a link on the breadcrumbs and remove all the links after that.


Here is my code:

 <Breadcrumbs id="bread" currentLocationText="{/sNode}">
 </Breadcrumbs>
         <Tree
            id="Tree"
            items="{path: '/'}"
            toggleOpenState="onToggle">
            <StandardTreeItem id="item" title="{title}" type="Navigation" press="test"/>
        </Tree>

And the controller:

onToggle: function(oEvent) {

            var lItem = oEvent.getParameters().itemContext.sPath;

            var nodes = this.getView().getModel().getProperty(lItem);
            var sNode = this.getView().getModel().getProperty(lItem).title;
            var oBreadCrumbs = this.byId("bread");
            
            arr.push(sNode);
          
            oBreadCrumbs.removeAllLinks();
            for(var i=0; i<arr.length; i++){
                if(i == arr.length -1){
                    oBreadCrumbs.setCurrentLocationText(arr[i]);
                }
                else{
                    var link = new sap.m.Link({
                        text: arr[i],
                        press: this.generateLinks
                    });
                    oBreadCrumbs.addLink(link);
                }
                
            }

           },

generateLinks : function(oEvent)
           {    
               var t = oEvent.getSource();
               console.log(t)
           },

At this moment I am just able to have the text of the pressed link. Any ideas how can I continue?