2
votes

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

1 Answers