У меня есть форма Ajax на мой взгляд. И сетка Кендо, которая отображается в частичном представлении в представлении.Обновить сетку Kendo на PartialViewРезультат обновления
@using (Ajax.BeginForm("AddToCatalogue", "Home", new AjaxOptions { UpdateTargetId = "catalogueSummary", InsertionMode = InsertionMode.Replace }, new { id = "addToCatalogueForm" }))
{
<input type="submit" class="button radius hide" id="btnAdd" value="Add to Catalogue" />
}
@Html.Partial("~/Views/Home/_CatalogueSummary.cshtml", Model.CatalogueItem)
В парциальное у меня есть сетка:
@using Web.Models @model IEnumerable
<div class="row">
<div class="panel">
<h5>Summary</h5>
<div id="divGrid">
@(Html.Kendo().Grid(Model)
.Name("catalogueSummaryGrid")
.Columns(columns =>
{
columns.Bound(c => c.Name);
columns.Bound(c => c.Length);
columns.Bound(c => c.Description);
columns.Bound(c => c.Ref);
})
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.Group(groups => groups.Add(p => p.Type))
.ServerOperation(false))
)
</div>
</div>
</div>
SO Я обжиг обновление из-за частичного в основном мало, вызвав иск:
[HttpPost]
public PartialViewResult AddToCatalogue()
{
// Get the current state of this catalogue
var api = new ServerApi<WebCatalogue>();
var webCatalogue = api.GetRequest("WebCatalogue").Result;
// Set up the UX state
var catalogueItems = new List<CatalogueItem>();
// Begin with existing items prior to this post
catalogueItems.AddRange(JsonConvert.DeserializeObject<List<CatalogueItem>>(webCatalogue.Data));
// Add in the dummy item
var newItem = new CatalogueItem()
{
Type= "Single",
Name = "Mark",
Length = 5,
Description = "some desc",
Ref = "Ref 1"
};
catalogueItems.Add(CatalogueItem);
// Apply the new UX state to the WebCatalogue and post it to the web api method
var newItems = JsonConvert.SerializeObject(catalogueItems);
webCatalogue.Data = newItems;
api.PostRequest("WebCatalogue", webCatalogue);
// Return the refreshed view
return this.PartialView("_CatalogueSummary", catalogueItems);
}