Telerik Extensions for ASP.NET MVC

Version Q1 2012, released 04/19/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);
}

Get more than expected!

Take the Telerik Extensions for ASP.NET MVC to your Visual Studio projects to truly experience their power. Download your free copy now and jumpstart your development with the available learning resources.

The Extensions are offered in both open source and commercial versions the differences between which are well explained in the licensing FAQ.

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

Other Demos: