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

[Solved] Dynamicly loading content on demand witch BindTo method

5 Answers 148 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.
Przemek
Top achievements
Rank 1
Przemek asked on 23 May 2011, 02:20 PM
Hi
I'm trying to dynamicly load content on tabs, who are binded from model.
LiadContentFrom method exists only in static tabs declatarion (tabStrip.Add())
How can i do this?

5 Answers, 1 is accepted

Sort by
0
nachid
Top achievements
Rank 1
answered on 23 May 2011, 03:11 PM
So what's wrong with the way it is today?
You declare your url and when you select the tab you get an ajax request that loads the data.
What do you want to do else ?
0
Przemek
Top achievements
Rank 1
answered on 25 May 2011, 09:53 AM
Controller
public
ActionResult _MyView()
{
    return PartialView();
}
When i try code bellow after select the tab page redirects me to _MyView. Doesn't render the _MyView as tab content.
View:
@(Html.Telerik().TabStrip()
    .Name("DocumentTabStrip")
    .BindTo(Model,
        (item, nData) =>
        {
            item.Text = nData.Name;
            item.Url = "_MyView";
        })
    )

This same behavior goes when i try this code:
@(Html.Telerik().TabStrip()
    .Name("DocumentTabStrip")
    .BindTo(Model,
        (item, nData) =>
        {
            item.Text = nData.Name;
            item.ActionName = "_MyView";
            item.ControllerName = "MyCont";
        })
    )

0
nachid
Top achievements
Rank 1
answered on 25 May 2011, 10:55 AM
Try this
  
@(Html.Telerik().TabStrip()
            .Name("DocumentTabStrip")
            .Items(tabstrip =>{   tabstrip.Add()
                                  .Text("Title")
                                  .LoadContentFrom(@"_MyView", @"Controller Name");
                          })

0
Przemek
Top achievements
Rank 1
answered on 25 May 2011, 11:01 AM
This solution works fine when i know how many tabs i want to create.
But i'm getting data for creating tab collection from model.
In my solution i need to create 1 static tab and few tabs from model. To build static tab i was used tabstrip.Add() but i have issue with binded from model...
0
nachid
Top achievements
Rank 1
answered on 25 May 2011, 03:28 PM
I never worked with bindTo and all I can say is to follow the way it is done in the sample page
http://demos.telerik.com/aspnet-mvc/tabstrip/databindingtomodel

They say to bind a tabstrip to a list of objects you should pass two paremeters to the BindTo method
  • a datasource as the first parameter. Ienumerable<T> datasource
  • an Action<TabStripItem>  as the second parameter.  Action<tabStripItem, T> itemDataBound

I cannot guess from your code that your model is an Ienumerable<nData>
Is that really the case?
Tags
TabStrip
Asked by
Przemek
Top achievements
Rank 1
Answers by
nachid
Top achievements
Rank 1
Przemek
Top achievements
Rank 1
Share this question
or