Custom Row/Cell Styling

Id First Name Last Name Start Date Status Gender
370PatrickAdams1/3/2015InactiveMaleView
493KarenAdams1/25/2014ActiveFemaleView
570NancyAdams6/14/2014InactiveFemaleView
599EricAdams12/10/2013InactiveMaleView
635ChristineAdams10/13/2011InactiveFemaleView
663BonnieAdams10/27/2011InactiveFemaleView
778RonaldAdams8/19/2011InactiveMaleView
820SeanAdams4/2/2014InactiveMaleView
897JudithAdams2/25/2013ActiveFemaleView
857MichaelAlexander6/23/2014ActiveMaleView
Showing 1 to 10 of 1000 entries

Code

Inside MVCGridConfig.cs
MVCGridDefinitionTable.Add("StyledGrid", new MVCGridBuilder<Person>(colDefauls)
    .WithAuthorizationType(AuthorizationType.AllowAnonymous)
    .AddColumns(cols =>
    {
        cols.Add("Id").WithSorting(false)
            .WithValueExpression(p => p.Id.ToString());
        cols.Add("FirstName").WithHeaderText("First Name")
            .WithValueExpression(p => p.FirstName);
        cols.Add("LastName").WithHeaderText("Last Name")
            .WithValueExpression(p => p.LastName);
        cols.Add("StartDate").WithHeaderText("Start Date")
            .WithValueExpression(p => p.StartDate.HasValue ? p.StartDate.Value.ToShortDateString() : "");
        cols.Add("Status").WithSortColumnData("Active")
            .WithHeaderText("Status")
            .WithValueExpression(p => p.Active ? "Active" : "Inactive");
        cols.Add("Gender").WithValueExpression(p => p.Gender)
            .WithCellCssClassExpression(p => p.Gender == "Female" ? "danger" : "warning");
        cols.Add().WithColumnName("ViewLink")
            .WithSorting(false)
            .WithHeaderText("")
            .WithHtmlEncoding(false)
            .WithValueExpression((p, c) => c.UrlHelper.Action("detail", new { id = p.Id }))
            .WithValueTemplate("<a href='{Value}'>View</a>");
    })
    .WithRowCssClassExpression(p => p.Active ? "success" : "")
    .WithSorting(true, "LastName")
    .WithPaging(true, 10)
    .WithRetrieveDataMethod((context) =>
    {
        var options = context.QueryOptions;
        int totalRecords;
        var repo = DependencyResolver.Current.GetService<IPersonRepository>();
        string sortColumn = options.GetSortColumnData<string>();
        var items = repo.GetData(out totalRecords, options.GetLimitOffset(), options.GetLimitRowcount(),
            sortColumn, options.SortDirection == SortDirection.Dsc);
        return new QueryResult<Person>()
        {
            Items = items,
            TotalRecords = totalRecords
        };
    })
);
View
@Html.MVCGrid("StyledGrid")