2

Giving a little background info:

Details.cshtml contains a title (uses model Category), I have a partial view that uses the Telerik MVC3 Grid and I wanted to implement the Ajax functionality (no documentation anywhere using Razor) on it and load the CategoryItems for the Category model that is used on the Details.cshtml but cannot find documentation on Partial views for MVC anywhere either.

Details.cshtml

@model TestStore.Models.Category

@{
    ViewBag.Title = "Details";
}

<fieldset>
    <legend>Category</legend>

    <div class="display-label">Name</div>
    <div class="display-field">@Model.Name</div>

    <div class="display-label">CreatedDate</div>
    <div class="display-field">@String.Format("{0:g}", Model.CreatedDate)</div>   
</fieldset>

    @Html.Partial("CategoryItemsList", Model.CategoryItems) // this is the line I have no clue for
<p>
    @Html.ActionLink("Edit", "Edit", new { id=Model.Id }) |
    @Html.ActionLink("Back to List", "Index")
</p>

CategoryItemsList.cshtml

@model IEnumerable<TestStore.Models.CategoryItem>

@(
    Html.Telerik().Grid(Model).Name("ItemGrid")
        .DataKeys(dataKeys => dataKeys.Add(o => o.Id))
        .Columns(columns => 
        {
            columns.Bound(o => o.Id).Hidden(true);         
            columns.Bound(o => o.Name);
            columns.Bound(o => o.CreatedDate);
        })
        .DataBinding(dataBinding =>
                                dataBinding.Ajax().Select("_AjaxBinding", "ItemGrid")
                    )
        .Pageable()
        .Sortable()
    )

Now, my question...what is the correct syntax to call the partial view with a different model without sending the data to it because I want that loaded via the Ajax calls...

and many many apologies if this has already be asked/answered..

1 Answer 1

2

Does not answer all of your questions but this should help you greatly.

http://www.arrangeactassert.com/when-to-use-html-renderpartial-and-html-renderaction-in-asp-net-mvc-razor-views/

Sign up to request clarification or add additional context in comments.

4 Comments

Ok, so, according to that, a partial view is not used like a user control in web forms...it's just templated html?
Templated html yeah you could say that. Your site layout _layout.cshtml is a partial view that renders your views within it.
So, in the case of the link you referenced, they've created a blog with MVC, and on the Blog Post page, they use a partial to load the comments. I've done that and it works fine (because Comments are a collection property to the Blog model) and each comment is rendered. Problem I have, is that I'm attempting to use the Telerik grid inside of a partial AND use the Ajax functionality (which I'm so tired of looking for answers I'm sick of them now), so, I give up...
Did you ever get a solution for this? I am looking to do the exact same thing and am looking for a solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.