TabStrip BindTo content using Action

4 posts, 1 answers
  1. Nate
    Nate avatar
    7 posts
    Member since:
    Mar 2015

    Posted 09 Apr 2015 Link to this post

    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
        })
    )

  2. Nate
    Nate avatar
    7 posts
    Member since:
    Mar 2015

    Posted 09 Apr 2015 in reply to Nate Link to this post

    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.

  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Nate
    Nate avatar
    7 posts
    Member since:
    Mar 2015

    Posted 09 Apr 2015 Link to this post

    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.
  5. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 13 Apr 2015 Link to this post

    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.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready