1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Bind Pages Facade to a Menu

Bind Pages Facade to a Menu

5 posts, 0 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    13 Feb 2011
    Link to this post
    Is there a sample somewhere on binding pages to a RadMenu as per the sitemap in the backend?

    This is what I have
    var pages = App.WorkWith()
                        .Pages()
                        .ThatArePublished()
                        .Where(x => x.ShowInNavigation == true &&
                               x.IsBackend == false &&
                               x.Ordinal > 0)
                        .Get();
     
    menu.DataSource = pages.OrderBy(x => x.Ordinal);
    menu.DataBind();

    But not only do they not come out in the right order, there's subpages in the root...

    What am I doing wrong? (I assume this is flattening it out?)
  2. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    15 Feb 2011
    Link to this post
    Hello Steve,

    You are right, the list you get back is flattened. The fluent API is used to work with data objects but it doesn't guarantee preserving the hierarchy of pages - that is a job for the sitemap. Is there any particular reason you want to use the fluent API in this case? Here's how I bound a RadMenu to the sitemap:

    var ds = SiteMap.RootNode.ChildNodes;
    this.menu.DataFieldParentID = "Key";
    this.menu.DataSource = ds;
    this.menu.DataBind();


    Regards,
    Slavo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    15 Feb 2011
    Link to this post
    ShowInNavigation is the problem I'm having, the SiteMap doesn't seem to respect it...
  4. Rein
    Rein avatar
    22 posts
    Registered:
    07 Oct 2008
    16 Feb 2011
    Link to this post
    It appears this has not been implemented yet. When working with plain LINQ queries like the code below an error pops up as soon as I add the "where o.ShowInNavigation" statement.

    var mgr = PageManager.GetManager();
    var nodes = mgr.GetPageNodes();
     
    var q = (from o in nodes
          where o.ShowInNavigation
          select o);
  5. Teodor
    Teodor avatar
    52 posts
    Registered:
    24 Sep 2012
    21 Feb 2011
    Link to this post
    Hi Rein,

    Hi there is a bug in the link parser. To workaround it you should use :

    o.ShowInNavigation == true

    instead only o.ShowInNavigation.


    var mgr = PageManager.GetManager();
                var nodes = mgr.GetPageNodes();
     
                var q = (from o in nodes
                         where o.ShowInNavigation == true
                         select o).ToList();


    Best wishes,
    Teodor
    the Telerik team
5 posts, 0 answered