This is a migrated thread and some comments may be shown as answers.

[Solved] Question loading control/view as child items

1 Answer 37 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jason
Top achievements
Rank 1
Jason asked on 12 Aug 2010, 10:40 PM

Environment:
1. ASP.NET MVC version - MVC 2
2. OS - Windows XP
3. exact browser version - IE 8
4. exact version of the Telerik product - Q2 2010 Beta
5. preferred programming language (VB.NET or C#) - C#

I have a situation where I have an object collection "StackCollection" that contains a list of the following object: 

    public class StackInfo
    {
        public string ControlPath { get; set; }
        public string ImageURL { get; set; }
        public int Index { get; set; }
        public string Text { get; set; }
    }

An example of the data I have in the collection is (pulled from a config file):

    <StackCollection>
      <add Text="PO Confirmation" ImageURL="~/content/navigation/toolbar/new.png" ControlPath="/Navigation/POConfirmationNav" Index="0"/>
      <add Text="SKU Validation" ImageURL="~/content/navigation/toolbar/new.png" ControlPath="/Navigation/SKUValidationNav" Index="1"/>
    </StackCollection>

I need to bind this collection to PanelBar that Displays the Image and Text as PanelBarItems and loads the .ascx control listed in the ControlPath property as a child item in the Items collection.  Can someone tell me how I can accomplish this?  I have tried numerous things.  Currently, my View and Controler looks like this:

    public class NavigationController : Controller
    {
        public ActionResult LeftNav()
        {
            return View();
        }

        public ActionResult SkuValidationNav()
        {
            //var item = new PanelBarItem();
            //item.??? = this.PartialView("SkuValidation");
           return View();
        }
    }

My LeftNav partial View has this:

 <% Html.Telerik().PanelBar()
       .Name("LeftNavPanelBar")
       .ExpandMode(PanelBarExpandMode.Multiple)
       .Theme("Office2007")

       .BindTo(UIStandardSettings.Settings.StackCollection, mappings =>
       {
           mappings.For<StackInfo>(binding => binding
               .ItemDataBound((item, si) =>
               {
                   item.Text = si.Text;
                   item.ImageUrl = si.ImageURL;
                   item.Expanded = true;
                   item.Items.Add(new PanelBarItem(){ ControllerName = si.ControlPath});
               })
              
               );
       }).Render(); 
       %>
 
I have it working to the point that I can display the Image and Text, but I am stuck on how to load the child control/view.

Thanks,
Jason

1 Answer, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 13 Aug 2010, 07:51 AM
Hello Jason,

 You can use the ContentUrl property of the item in the ItemDataBound handler

item.ContentUrl = Url.Action("action", "controller");

All the best,
Atanas Korchev
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
Tags
PanelBar
Asked by
Jason
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or