Telerik Extensions for ASP.NET MVC

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

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: