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

How to change routeValues or content Url after initialization?

1 Answer 472 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Iron
Tom asked on 20 Oct 2017, 12:45 PM

I have a tabstrip that loads its content from partial views, and this works well provided the routeValues never change. For example:

@(Html.Kendo().TabStrip()
    .Name("MyTabStrip")
    .Items(i =>
    {
        i.Add().Text("First Tab").LoadContentFrom("FirstAction", "MyController", new { id = ViewData["id"]  });
        i.Add().Text("Second Tab").LoadContentFrom("SecondAction", "MyController", new { id = ViewData["id"] });
    })
)

This will hit FirstAction and SecondAction when the tabs are selected, and carry the id along from ViewData, this is fine.

...but if "id" is a more dynamic bit of data, that needs to change on the page, this approach is no longer valid.  

The TabStrips do not have any Data function, akin to what can be found in the Read attribute in a regular DataSource, which would have been nice, and there is nothing too helpful in the Select event of the TabStrip. I have tried editing the _contentUrls list inside the TabStrip element, but this does not seem to work, either; it seems this is populated when the element is created, but not actually used.

...so how can this be done? Is there any way to update the content urls of an existing tab?

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 24 Oct 2017, 08:47 AM
Hello Tom,

After the TabStrip is initialized the controller and action a specific tab loads its content from can be changed with the help of the widget's reload method, as shown below:
<input type="button" value="Reload Second Tab" onclick="reloadTab()" />
<script>   
    function reloadTab () {
        var tabstrip = $("#MyTabStrip").data("kendoTabStrip");
        var item = tabstrip.contentElement(0);
 
        $(".k-link:contains('Second Tab')").data('contentUrl', '/MyController/MyAction');
        tabstrip.reload("li:eq(1)");
    }
</script>


Regards,
Ivan Danchev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
TabStrip
Asked by
Tom
Top achievements
Rank 1
Iron
Answers by
Ivan Danchev
Telerik team
Share this question
or