I read http://www.kendoui.com/code-library/mvc/grid/binding-to-a-web-apicontroller.aspx , but remote WebApi not work
@(Html.Kendo().Grid<
KendoUIMvcApplication3.Models.Product
>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.ProductName);
columns.Bound(p => p.UnitsInStock);
columns.Command(c =>
{
c.Edit();
c.Destroy();
});
})
.ToolBar(tools =>
{
tools.Create();
})
.Sortable()
.Pageable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Model(model =>
{
model.Id(p => p.ProductID);
})
.Read(read => read.Url("http://192.168.1.10:699/api/Product").Type(HttpVerbs.Get))
.Create(create => create.Url("http://192.168.1.10:699/api/Product").Type(HttpVerbs.Post))
.Update(update => update.Url("http://192.168.1.10:699/api/Product").Type(HttpVerbs.Put))
.Destroy(destroy => destroy.Url("http://192.168.1.10:699/api/Product").Type(HttpVerbs.Delete))
)
)
<
script
>
$(function() {
var grid = $("#Grid").data("kendoGrid");
// WebAPI needs the ID of the entity to be part of the URL e.g. PUT /api/Product/80
grid.dataSource.transport.options.update.url = function(data) {
return "http://192.168.1.10:699/api/Product/" + data.ProductID;
};
// WebAPI needs the ID of the entity to be part of the URL e.g. DELETE /api/Product/80
grid.dataSource.transport.options.destroy.url = function(data) {
return "http://192.168.1.10:699/api/Product/" + data.ProductID;
};
});
</
script
>