将kendo网格绑定到本地数据,它是ajax当前页面(" http://localhost"),如何解决? 页面加载时,当前页面(" http://localhost")会获得2次。
我的观点
@(Html.Kendo().Grid<Models.RecordModel>()
.Name("ResultGrid")
.Columns(columns =>
{
columns.Bound(p => p.ProductTitle).Width(250).Title("Title").HtmlAttributes(new {@class = "GridTextLeft"});
columns.Bound(p => p.ProductCode).Width(110).Title("Code").HtmlAttributes(new {@class = "GridTextLeft"});
})
.Scrollable(scr => scr.Height(380))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.PageSize(10)
.Model(model =>
{
model.Id(p => p.ProductId);
model.Field(p => p.ProductTitle);
model.Field(p => p.ProductCode);
})
)
.Resizable(resize => resize.Columns(true))
.Pageable(pager => pager
.ButtonCount(1)
.PreviousNext(true)
.Messages(t => t.Display("{2} item"))
)
)
答案 0 :(得分:1)
需要将Kendo Grid指向您的控制器方法,如果它是Ajax绑定则返回数据:
...
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Products_Read", "Home")) //Set the action method which will return the data in JSON format.
)
)
...
查看http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/binding/ajax-binding处的手册。
更新。如果您需要服务器绑定,请按照http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/binding/server-binding
应用BindTo
方法