MVC 4와 함께 Kendo UI Grid를 사용하고 있으며 단 한 가지 예외가 있습니다.Kendo MVC fire 업데이트 호출시 메서드 만들기
그리드에 행을 추가하고 행을 업데이트 한 후에 행을 업데이트하는 대신 결국 행이 추가됩니다. 내가 말할 수있는 무엇
내가 추가 누르면, 프로그램은 내가 후 행 에 추가 업데이트를 눌러 경우 내가 가 다시 한번 방법을 만들기 입력, 내 MVC 컨트롤러에 방법을 만들기 입력하는 것입니다.
그러나 시작 후 바로 그리드의 업데이트 버튼을 누르면이 경우가 아닌 것 같습니다. Ajax 호출로이 모든 작업을 수행하므로 호출간에 업데이트되지 않는 페이지와 관련이 있습니다. 모든 명령은 명령을 하나만 수행하고 페이지를 새로 고치면 훌륭하게 작동합니다. 또한 ORM으로 Entity Framework를 사용하고 있습니다.
@model IEnumerable<Internal.License.Management.Web.UI.Models.PriceListViewModel>
@{
ViewBag.Title = "Price List";
}
@(Html.Kendo().Grid<Internal.License.Management.Web.UI.Models.PriceListViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.Name).Width(120);
columns.Bound(p => p.Code).Width(180);
columns.Bound(p => p.Interval).Width(180);
columns.Bound(p => p.PricePerUnit).Width(200);
columns.Bound(p => p.Currency).Width(120);
columns.Command(commands =>
{
commands.Edit();
commands.Destroy();
}).Width(172);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource =>
dataSource.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.Id))
.Create(create => create.Action("Create", "PriceList"))
.Read(read => read.Action("Read", "PriceList"))
.Update(update => update.Action("Update", "PriceList"))
.Destroy(destroy => destroy.Action("Delete", "PriceList"))
))
이
내 컨트롤러 :이
내 면도날이다이public class PriceListController : Controller
{
public ActionResult List()
{
return View("PriceList");
}
public ActionResult Read([DataSourceRequest] DataSourceRequest request)
{
var model = new DataAdapter().GetAllOptionTemplates();
var result = model.ToDataSourceResult(request);
return Json(result);
}
[HttpPost]
public ActionResult Create([DataSourceRequest] DataSourceRequest request,
PriceListViewModel model)
{
if (model != null && ModelState.IsValid)
{
new DataAdapter().SaveToDatabase(model);
}
return Json(new[] { model }.ToDataSourceResult(request, ModelState));
}
[HttpPost]
public ActionResult Update([DataSourceRequest] DataSourceRequest request,
PriceListViewModel model)
{
if (model != null && ModelState.IsValid)
{
new DataAdapter().UpdateToDatabase(model);
}
return Json(ModelState.ToDataSourceResult());
}
}
내보기 모델
public class PriceListViewModel
{
public int Id { get; set; }
public string Currency { get; set; }
[DisplayName("Option Name")]
public string Name { get; set; }
public string Code { get; set; }
public string Interval { get; set; }
public decimal PricePerUnit { get; set; }
}
나는 OP와 같은 문제가 있었는데,이 문제가 해결되었습니다. telerik이 이드가 더 이상 새로운 아이템이 아니라는 것을 알 필요가있는 것처럼 보입니다. – Eregrith