Functionality on Breadcrumbs navigation
I am trying to extend the basic tree example and add a breadcrumbs navigation on top.
View
<mvc:View
controllerName="sap.m.sample.Tree.Page"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<Breadcrumbs id="bread" currentLocationText="/sNode">
</Breadcrumbs>
<Tree
id="Tree"
items="path: '/'"
toggleOpenState="onToggle">
<StandardTreeItem id="item" title="title" type="Navigation" press="test"/>
</Tree>
Controller
onInit: function(evt)
// set explored app's demo model on this sample
var oModel = new JSONModel(jQuery.sap.getModulePath("sap.m.sample.Tree", "/Tree.json"));
var data = this.getView().setModel(oModel);
,
onToggle: function(oEvent)
var lItem = oEvent.getParameters().itemContext.sPath;
var lItem2 = oEvent.getParameter("itemContext");
var nodes = this.getView().getModel().getProperty(lItem);
var sNode = this.getView().getModel().getProperty(lItem).title;
var oBreadCrumbs = this.byId("bread");
if (!(paths.includes(lItem)))
arr.push(sNode);
else
var index = arr.indexOf(sNode);
paths.length = index + 1;
arr.length = index + 1;
paths.push(lItem);
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.tryOne, oBreadCrumbs]
);
oBreadCrumbs.addLink(link);
,
tryOne: function(oEvent)
var t = oEvent.getSource();
var n = this.indexOfLink(t);
this.removeAllLinks();
this.setCurrentLocationText(arr[n]);
for (var i = 0; i < n; i++)
var li = new sap.m.Link(
text: arr[i],
press: ? ? ? ?
);
this.addLink(li);
,
So what I am doing now is when a node of the tree expanded, the title added to the breadcrumbs navigation as a Link. What I want now, is when a user presses a link on the breadcrumbs navigation, all the links after the pressed one, should be removed and the pressed one should be the current Location.
With the function tryOne
, I am repeating the whole procedure by find the last clicked element, add it in an array, remove everything and finally attach again the array to the links control.
My problem is that this function is working properly only for the first time. After the second time it stops working. Any ideas please?
javascript json tree sapui5 breadcrumbs
add a comment |
I am trying to extend the basic tree example and add a breadcrumbs navigation on top.
View
<mvc:View
controllerName="sap.m.sample.Tree.Page"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<Breadcrumbs id="bread" currentLocationText="/sNode">
</Breadcrumbs>
<Tree
id="Tree"
items="path: '/'"
toggleOpenState="onToggle">
<StandardTreeItem id="item" title="title" type="Navigation" press="test"/>
</Tree>
Controller
onInit: function(evt)
// set explored app's demo model on this sample
var oModel = new JSONModel(jQuery.sap.getModulePath("sap.m.sample.Tree", "/Tree.json"));
var data = this.getView().setModel(oModel);
,
onToggle: function(oEvent)
var lItem = oEvent.getParameters().itemContext.sPath;
var lItem2 = oEvent.getParameter("itemContext");
var nodes = this.getView().getModel().getProperty(lItem);
var sNode = this.getView().getModel().getProperty(lItem).title;
var oBreadCrumbs = this.byId("bread");
if (!(paths.includes(lItem)))
arr.push(sNode);
else
var index = arr.indexOf(sNode);
paths.length = index + 1;
arr.length = index + 1;
paths.push(lItem);
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.tryOne, oBreadCrumbs]
);
oBreadCrumbs.addLink(link);
,
tryOne: function(oEvent)
var t = oEvent.getSource();
var n = this.indexOfLink(t);
this.removeAllLinks();
this.setCurrentLocationText(arr[n]);
for (var i = 0; i < n; i++)
var li = new sap.m.Link(
text: arr[i],
press: ? ? ? ?
);
this.addLink(li);
,
So what I am doing now is when a node of the tree expanded, the title added to the breadcrumbs navigation as a Link. What I want now, is when a user presses a link on the breadcrumbs navigation, all the links after the pressed one, should be removed and the pressed one should be the current Location.
With the function tryOne
, I am repeating the whole procedure by find the last clicked element, add it in an array, remove everything and finally attach again the array to the links control.
My problem is that this function is working properly only for the first time. After the second time it stops working. Any ideas please?
javascript json tree sapui5 breadcrumbs
your function uses variables coming from upper scope 'paths' & 'arr' making it hard to understand + when you say it works only the first time, what happens the second time ?
– Ash Kander
Nov 15 '18 at 6:36
oh yes you are right. There two arrays are two empty arrays which are declared outside of the function. When the navigation is created for the first time, when a link is clicked, the program goes to tryOne function. The navigation is created again there. My problem is that I don;t know what should I rum when a link pressed from tryOne function (this is why I hjave the press:???)
– marissalianam
Nov 15 '18 at 8:53
Possible duplicate of Use breadcrumbs with tree dynamically SAPUI
– fabiopagoti
Nov 15 '18 at 12:20
No, here I am stuck ina totally different point. I have the breadcrumbs created dynamically, but the links are not working! I need when a link is pressed to remove all the links after that. And I am trying to do this, with the function tryOne.
– marissalianam
Nov 16 '18 at 14:37
Can you please paste this code into JSBin or a Stack Snippet in the question itself, so I can run it and debug the issue?
– Breakpoint
Nov 20 '18 at 19:42
add a comment |
I am trying to extend the basic tree example and add a breadcrumbs navigation on top.
View
<mvc:View
controllerName="sap.m.sample.Tree.Page"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<Breadcrumbs id="bread" currentLocationText="/sNode">
</Breadcrumbs>
<Tree
id="Tree"
items="path: '/'"
toggleOpenState="onToggle">
<StandardTreeItem id="item" title="title" type="Navigation" press="test"/>
</Tree>
Controller
onInit: function(evt)
// set explored app's demo model on this sample
var oModel = new JSONModel(jQuery.sap.getModulePath("sap.m.sample.Tree", "/Tree.json"));
var data = this.getView().setModel(oModel);
,
onToggle: function(oEvent)
var lItem = oEvent.getParameters().itemContext.sPath;
var lItem2 = oEvent.getParameter("itemContext");
var nodes = this.getView().getModel().getProperty(lItem);
var sNode = this.getView().getModel().getProperty(lItem).title;
var oBreadCrumbs = this.byId("bread");
if (!(paths.includes(lItem)))
arr.push(sNode);
else
var index = arr.indexOf(sNode);
paths.length = index + 1;
arr.length = index + 1;
paths.push(lItem);
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.tryOne, oBreadCrumbs]
);
oBreadCrumbs.addLink(link);
,
tryOne: function(oEvent)
var t = oEvent.getSource();
var n = this.indexOfLink(t);
this.removeAllLinks();
this.setCurrentLocationText(arr[n]);
for (var i = 0; i < n; i++)
var li = new sap.m.Link(
text: arr[i],
press: ? ? ? ?
);
this.addLink(li);
,
So what I am doing now is when a node of the tree expanded, the title added to the breadcrumbs navigation as a Link. What I want now, is when a user presses a link on the breadcrumbs navigation, all the links after the pressed one, should be removed and the pressed one should be the current Location.
With the function tryOne
, I am repeating the whole procedure by find the last clicked element, add it in an array, remove everything and finally attach again the array to the links control.
My problem is that this function is working properly only for the first time. After the second time it stops working. Any ideas please?
javascript json tree sapui5 breadcrumbs
I am trying to extend the basic tree example and add a breadcrumbs navigation on top.
View
<mvc:View
controllerName="sap.m.sample.Tree.Page"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<Breadcrumbs id="bread" currentLocationText="/sNode">
</Breadcrumbs>
<Tree
id="Tree"
items="path: '/'"
toggleOpenState="onToggle">
<StandardTreeItem id="item" title="title" type="Navigation" press="test"/>
</Tree>
Controller
onInit: function(evt)
// set explored app's demo model on this sample
var oModel = new JSONModel(jQuery.sap.getModulePath("sap.m.sample.Tree", "/Tree.json"));
var data = this.getView().setModel(oModel);
,
onToggle: function(oEvent)
var lItem = oEvent.getParameters().itemContext.sPath;
var lItem2 = oEvent.getParameter("itemContext");
var nodes = this.getView().getModel().getProperty(lItem);
var sNode = this.getView().getModel().getProperty(lItem).title;
var oBreadCrumbs = this.byId("bread");
if (!(paths.includes(lItem)))
arr.push(sNode);
else
var index = arr.indexOf(sNode);
paths.length = index + 1;
arr.length = index + 1;
paths.push(lItem);
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.tryOne, oBreadCrumbs]
);
oBreadCrumbs.addLink(link);
,
tryOne: function(oEvent)
var t = oEvent.getSource();
var n = this.indexOfLink(t);
this.removeAllLinks();
this.setCurrentLocationText(arr[n]);
for (var i = 0; i < n; i++)
var li = new sap.m.Link(
text: arr[i],
press: ? ? ? ?
);
this.addLink(li);
,
So what I am doing now is when a node of the tree expanded, the title added to the breadcrumbs navigation as a Link. What I want now, is when a user presses a link on the breadcrumbs navigation, all the links after the pressed one, should be removed and the pressed one should be the current Location.
With the function tryOne
, I am repeating the whole procedure by find the last clicked element, add it in an array, remove everything and finally attach again the array to the links control.
My problem is that this function is working properly only for the first time. After the second time it stops working. Any ideas please?
javascript json tree sapui5 breadcrumbs
javascript json tree sapui5 breadcrumbs
edited Nov 16 '18 at 14:35
marissalianam
asked Nov 14 '18 at 15:42
marissalianammarissalianam
2217
2217
your function uses variables coming from upper scope 'paths' & 'arr' making it hard to understand + when you say it works only the first time, what happens the second time ?
– Ash Kander
Nov 15 '18 at 6:36
oh yes you are right. There two arrays are two empty arrays which are declared outside of the function. When the navigation is created for the first time, when a link is clicked, the program goes to tryOne function. The navigation is created again there. My problem is that I don;t know what should I rum when a link pressed from tryOne function (this is why I hjave the press:???)
– marissalianam
Nov 15 '18 at 8:53
Possible duplicate of Use breadcrumbs with tree dynamically SAPUI
– fabiopagoti
Nov 15 '18 at 12:20
No, here I am stuck ina totally different point. I have the breadcrumbs created dynamically, but the links are not working! I need when a link is pressed to remove all the links after that. And I am trying to do this, with the function tryOne.
– marissalianam
Nov 16 '18 at 14:37
Can you please paste this code into JSBin or a Stack Snippet in the question itself, so I can run it and debug the issue?
– Breakpoint
Nov 20 '18 at 19:42
add a comment |
your function uses variables coming from upper scope 'paths' & 'arr' making it hard to understand + when you say it works only the first time, what happens the second time ?
– Ash Kander
Nov 15 '18 at 6:36
oh yes you are right. There two arrays are two empty arrays which are declared outside of the function. When the navigation is created for the first time, when a link is clicked, the program goes to tryOne function. The navigation is created again there. My problem is that I don;t know what should I rum when a link pressed from tryOne function (this is why I hjave the press:???)
– marissalianam
Nov 15 '18 at 8:53
Possible duplicate of Use breadcrumbs with tree dynamically SAPUI
– fabiopagoti
Nov 15 '18 at 12:20
No, here I am stuck ina totally different point. I have the breadcrumbs created dynamically, but the links are not working! I need when a link is pressed to remove all the links after that. And I am trying to do this, with the function tryOne.
– marissalianam
Nov 16 '18 at 14:37
Can you please paste this code into JSBin or a Stack Snippet in the question itself, so I can run it and debug the issue?
– Breakpoint
Nov 20 '18 at 19:42
your function uses variables coming from upper scope 'paths' & 'arr' making it hard to understand + when you say it works only the first time, what happens the second time ?
– Ash Kander
Nov 15 '18 at 6:36
your function uses variables coming from upper scope 'paths' & 'arr' making it hard to understand + when you say it works only the first time, what happens the second time ?
– Ash Kander
Nov 15 '18 at 6:36
oh yes you are right. There two arrays are two empty arrays which are declared outside of the function. When the navigation is created for the first time, when a link is clicked, the program goes to tryOne function. The navigation is created again there. My problem is that I don;t know what should I rum when a link pressed from tryOne function (this is why I hjave the press:???)
– marissalianam
Nov 15 '18 at 8:53
oh yes you are right. There two arrays are two empty arrays which are declared outside of the function. When the navigation is created for the first time, when a link is clicked, the program goes to tryOne function. The navigation is created again there. My problem is that I don;t know what should I rum when a link pressed from tryOne function (this is why I hjave the press:???)
– marissalianam
Nov 15 '18 at 8:53
Possible duplicate of Use breadcrumbs with tree dynamically SAPUI
– fabiopagoti
Nov 15 '18 at 12:20
Possible duplicate of Use breadcrumbs with tree dynamically SAPUI
– fabiopagoti
Nov 15 '18 at 12:20
No, here I am stuck ina totally different point. I have the breadcrumbs created dynamically, but the links are not working! I need when a link is pressed to remove all the links after that. And I am trying to do this, with the function tryOne.
– marissalianam
Nov 16 '18 at 14:37
No, here I am stuck ina totally different point. I have the breadcrumbs created dynamically, but the links are not working! I need when a link is pressed to remove all the links after that. And I am trying to do this, with the function tryOne.
– marissalianam
Nov 16 '18 at 14:37
Can you please paste this code into JSBin or a Stack Snippet in the question itself, so I can run it and debug the issue?
– Breakpoint
Nov 20 '18 at 19:42
Can you please paste this code into JSBin or a Stack Snippet in the question itself, so I can run it and debug the issue?
– Breakpoint
Nov 20 '18 at 19:42
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303863%2ffunctionality-on-breadcrumbs-navigation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303863%2ffunctionality-on-breadcrumbs-navigation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
your function uses variables coming from upper scope 'paths' & 'arr' making it hard to understand + when you say it works only the first time, what happens the second time ?
– Ash Kander
Nov 15 '18 at 6:36
oh yes you are right. There two arrays are two empty arrays which are declared outside of the function. When the navigation is created for the first time, when a link is clicked, the program goes to tryOne function. The navigation is created again there. My problem is that I don;t know what should I rum when a link pressed from tryOne function (this is why I hjave the press:???)
– marissalianam
Nov 15 '18 at 8:53
Possible duplicate of Use breadcrumbs with tree dynamically SAPUI
– fabiopagoti
Nov 15 '18 at 12:20
No, here I am stuck ina totally different point. I have the breadcrumbs created dynamically, but the links are not working! I need when a link is pressed to remove all the links after that. And I am trying to do this, with the function tryOne.
– marissalianam
Nov 16 '18 at 14:37
Can you please paste this code into JSBin or a Stack Snippet in the question itself, so I can run it and debug the issue?
– Breakpoint
Nov 20 '18 at 19:42