Telerik Extensions for ASP.NET MVC

Version Q2 2012, released 06/07/2012

Web Service Binding

Bound to ASMX Web Service

Drag a column header and drop it here to group by that column
No records to display.
Displaying items 0 - 0 of 0

Bound to WCF Web Service using DTO objects

Drag a column header and drop it here to group by that column
No records to display.
Displaying items 0 - 0 of 0

About this example ASPXRazor

This example shows how to bind Telerik Grid for ASP.NET MVC to web services.

You need to configure the grid via the DataBinding method

<%= Html.Telerik().Grid<Order>()
        .Name("AsmxGrid")
        .DataBinding(dataBinding => dataBinding.WebService().Select("~/Models/Orders.asmx/GetOrders"))
        .Columns(columns =>
        {
           columns.Bound(o => o.OrderID).Width(81);
           columns.Bound(o => o.Customer.ContactName).Width(200);
           columns.Bound(o => o.ShipAddress);
           columns.Bound(o => o.OrderDate).Format("{0:MM/dd/yyyy}").Width(100);
        })
        .Sortable()
        .Pageable()
        .Filterable()
        .Scrollable()
%>

The web service method should have a parameter of type GridState which represents the current grid state - page, sort, filter and group expressions.

The web service method 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 GetOrders(GridState state)
{
    NorthwindDataContext northwind = new NorthwindDataContext();

    return northwind.Orders.ToGridModel(state);
}

Interested in HTML5 and mobile-powered ASP.NET MVC apps?

Experience the next generation UI and framework for ASP.NET MVC development by downloading trial evaluation copy of Kendo UI Complete for ASP.NET MVC. Jumpstart your development with the available learning resources.

The differences between Telerik MVC Extensions and Kendo UI Complete for ASP.NET MVC, and their licensing models are explained here and here.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Other Demos: