Telerik Extensions for ASP.NET MVC

Version Q2 2012, released 06/07/2012

Custom Formatting

Order IDContact NameShip AddressFreight
10248Paul Henriot59 rue de l'Abbaye32.38
10249Karin JosephsLuisenstr. 4811.61
10250Mario PontesRua do Paço, 6765.83
10251Mary Saveley2, rue du Commerce41.34
10252Pascale CartrainBoulevard Tirou, 25551.30
10253Mario PontesRua do Paço, 6758.17
10254Yang WangHauptstr. 3122.98
10255Michael HolzStarenweg 5148.33
10256Paula ParenteRua do Mercado, 1213.97
10257Carlos HernándezCarrera 22 con Ave. Carlos Soublette #8-3581.91
Displaying items 1 - 10 of 830

About this example ASPXRazor

This example shows how to visually format the data in presented by Telerik Grid for ASP.NET MVC. Currently visual formatting works only in server binding mode.

You can use the RowAction method to format the entire row. It is executed for every single row of the grid.

<%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .RowAction(row =>
        {
            // "DataItem" is the Order object to which the current row is bound to
            if (row.DataItem.Freight > 10)
            {
                //Set the background of the entire row
                row.HtmlAttributes["style"] = "background:red;";
            }
        });
%>

You can also use the CellAction method to format a concrete cell only. It is executed for every single cell of the grid.

<%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .CellAction(cell =>
        {
            if (cell.Column.Name == "Freight")
            {
                if (cell.DataItem.Freight > 10)
                {
                    //Set the background of this cell only
                    cell.HtmlAttributes["style"] = "background:red;";
                }
            }
        });
%>

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: