Bind Pages Facade to a Menu

Posted by Community Admin on 03-Aug-2018 00:47

Bind Pages Facade to a Menu

All Replies

Posted by Community Admin on 13-Feb-2011 00:00

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?)

Posted by Community Admin on 15-Feb-2011 00:00

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

Posted by Community Admin on 15-Feb-2011 00:00

ShowInNavigation is the problem I'm having, the SiteMap doesn't seem to respect it...

Posted by Community Admin on 16-Feb-2011 00:00

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);

Posted by Community Admin on 21-Feb-2011 00:00

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

This thread is closed