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

[Solved] Change tab content from partial view within tab

0 Answers 67 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
ADS Development Team
Top achievements
Rank 1
ADS Development Team asked on 22 Jul 2011, 11:21 AM
Hi,

I created a TabStrip control within a partial view, I've bound it to a collection of items and set the ContentUrl to load another partial view when each tab is selected.

<h2>Home</h2>
 
@{ Html.Telerik().TabStrip()
        .Name("TabStrip")
        .BindTo((IEnumerable<ADSCatalogueData.TreeSource>)ViewData["treeSources"],
            (item, treeSource) =>
            {
                item.Text = treeSource.TreeSourceName;
                item.ContentUrl = Url.Action("ViewTreeSource", "Home", new { treeSourceId = treeSource.TreeSourceId });
            })
        .Render();
}

public PartialViewResult ViewTreeSource(string treeSourceId)
{
    List<TreeLevel> treeLevels = TreeLevel.GetTreeLevels(null, "0", "User", Convert.ToInt32(treeSourceId));
 
    return PartialView(treeLevels);
}

This works sometimes, but sometimes the view isn't loaded into the tab control and it takes up the whole browser, any ideas what could be causing this?

Also, the view that should be loaded into the tab control contains a number of links that when selected should reload the view with different data. Obvisouly I need this new data to be displayed in the tab control. Any ideas on how I could achieve this? The only solution I've come up with reloads the view with the new data but again it isn't displayed in the tab. The code below is the view that should always be displayed in the tab.

@model List<ADS.WebCatalogue.PartsCatalogue.Models.TreeLevel>
 
<table width=100%>
    <tr>
    @{ var i = 0; }
 
    @foreach (var tm in Model)
    {
        <td>@Html.ActionLink(@tm.Component, "ViewTreeSource", "Home", new { treeSourceId = "2" }, null)</td>
         
        if (++i % 3 == 0)
        {
            @:</tr><tr>
        }
    }
        
    </tr>
</table>

Thanks for your help.
Tags
TabStrip
Asked by
ADS Development Team
Top achievements
Rank 1
Share this question
or