I am using the latest version of Telerik MVC in my ASP.NET MVC3 application with razor .
I defined the grid structure as follows:
@(Html.Telerik() .Grid<GrantApplicationListViewModel>() .Name("grdGrantApplications") .Columns(column => { column.Bound(x => x.FullName) .Title("Owner") .Width(200); column.Bound(x => x.CreatedDate) .Title("Created") .Width(90); }) .DataBinding(dataBinding => dataBinding.Ajax().Select("AjaxGrantApplicationsBinding", "Home")) .Pageable(paging => paging.PageSize(30)) .TableHtmlAttributes(new { @class = "telerik-grid" }) )
My model looks like this:
public class GrantApplicationListViewModel { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string FullName { get { return FirstName + " " + LastName; } } public DateTime CreatedDate { get; set; } }
I created a date format that I would like to use in my column to format the date:
public static class DateTimeExtensions { public static string FormatDate(this DateTime instance) { return string.Format("{0:yyyy-MM-dd}", instance); } }
How to use this formatting method in my column to format CreateDate? I tried the following:
column.Bound(x => x.CreatedDate.FormatDate()) .Title("Created") .Width(90);
.. and I get the following error:
Bound columns require a field or property access expression.
source share