This example shows how to bind Telerik Grid for ASP.NET MVC to web services.
You need to configure the grid by using the WebService method
<%= Html.Telerik().Grid<Order>()
.Name("AsmxGrid")
.WebService(webService => webService.Url("~/Models/Orders.asmx/GetOrders"))
.Columns(columns =>
{
columns.Add(o => o.OrderID).Width(81);
columns.Add(o => o.Customer.ContactName).Width(200);
columns.Add(o => o.ShipAddress);
columns.Add(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(100);
})
.Sortable()
.Pageable()
.Filterable()
.Scrollable()
%>
The web service may return the GridModel object or any other object which has a Data and Total properties. To benefit from the built-in Linq expression engine you can use the ToGridModel extension method:
[WebMethod]
public GridModel<Order> GetOrders(int page, int size, string orderBy, string filter)
{
NorthwindDataContext northwind = new NorthwindDataContext();
return northwind.Orders.ToGridModel(page, size, orderBy, filter);
}