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

TabStrip BindTo content using Action

3 Answers 294 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Nate
Top achievements
Rank 1
Nate asked on 09 Apr 2015, 04:44 PM

So I originally defined a TabStrip and manually loaded the content using LoadContentFrom with an Action which returned a PartialView of content defined in another .cshtml. It worked fine.

Now I want to do something similar, but have the items of the TabStrip bound to a collection. The TabStrip is binding the text of the item just fine, but the Action to get the content is never being called. How do I define it so that it does, similar to LoadContentFrom?

If my old implementation is:

@(Html.Kendo().TabStrip()
    .Name("tabStrip")
    .Items(items => {
        items.Add().Text("Test").LoadContentFrom("MyAction","MyController", new { id = 0 });

     })

)

How do I translate that to:

@(Html.Kendo().TabStrip()
    .Name("tabStrip")
    .BindTo(Model, (item, category) =>
    {
        item.Text = category.TestText; // works
        item.Action("MyActions", "MyController", new { id = 0 }); // Doesn't seem to do anything
    })
)

3 Answers, 1 is accepted

Sort by
0
Nate
Top achievements
Rank 1
answered on 09 Apr 2015, 05:08 PM

So the way I got it to work was by manually setting the template string using Html.Action like so:
item.Template.Html = Html.Action("MyAction", "MyController", new { id = 0 }).ToHtmlString();

Is there a better way to do this? This seems to work well though.

0
Nate
Top achievements
Rank 1
answered on 09 Apr 2015, 06:42 PM
So the one issue about the method I used is that it is in no way on demand, so if I have a large data set (which I do), it's loading all of the HTML at once. I really need to find a way to set the load action to use instead of actually setting the content.
0
Accepted
Atanas Korchev
Telerik team
answered on 13 Apr 2015, 10:20 AM

Hello Nate,

Try the following:

BindTo(Model, (item, category) =>
    {
        item.Text = category.TestText; // works
        item.ContentUrl = Url.Action("MyActions", "MyController", new { id = 0 }); 
    })

 

Regards,
Atanas Korchev
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
TabStrip
Asked by
Nate
Top achievements
Rank 1
Answers by
Nate
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or