0

I have a site on share Point which contains some sub sites as well.I deployed my APP on main Site, I didn't include sub sites in top navigation but when I am using following code , it gives me Top Navigation bar as well as sub sites. I just want only top navigation not the sub sites how can I exclude sub site.

function getTopMenuBar() {

    clientContext = new SP.ClientContext.get_current();

    if (clientContext != undefined && clientContext != null) {

        parent_web = clientContext.get_site().get_rootWeb();
        navigation = parent_web.get_navigation();
        clientContext.load(navigation);
        quickLaunchNodeCollection = navigation.get_topNavigationBar();
        clientContext.load(quickLaunchNodeCollection);

        clientContext.executeQueryAsync(Function.createDelegate(this, this.OnLoadingNavigation), Function.createDelegate(this, this.onQueryFailed));

    }
}

function OnLoadingNavigation() {
    var nodeEnumerator = this.quickLaunchNodeCollection.getEnumerator();
    while(nodeEnumerator.moveNext()) {
        var node = nodeEnumerator.get_current();
}
}


function onQueryFailed(sender, args) {
    // Some Code
}
0

The reason this is happening is because the property "Display this site on the top link bar of the parent site?" has been set to true when creating a sub site. If this property of the sub sites is set to false, they won't appear in the top navigation bar of the parent site.

  • I set this property as NO while creating sub site. My App is on Parent Site not in sub site I am not getting sub site in menu on main site but by using following code I am getting sub site in menu in my APP – BASEER HAIDER JAFRI Feb 10 '15 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.