Table

FirstNameLastNameHomePhoneTitle

Actions

Validate Save

Sent To Server:

Config

    public class EmployeeTable : MvcTable<Employee>
    {
        public override void Configure(IStaticTableConfiguration<Employee> config)
        {
            var ents = new NorthwindEntities.NorthwindEntities(new Uri(ConfigurationManager.AppSettings["NorthwindUrl"]));
            var titles = ents.Employees.Select(t => new {t.Title}).ToArray().Select(t => t.Title).Distinct();

            config
                .SetAction("ListEmployees", "Northwind")
                .SetCssClass("table table-striped")
                .HiddenColumnFor(c => c.EmployeeID, cfg => cfg.Hide())
                .EditorForColumn(e => e.FirstName)
                .EditorForColumn(e => e.LastName)
                .EditorForColumn(e => e.HomePhone)
                .DropdownColumnFor(e => e.Title, titles, s => s, s => s)
                .ConfigurePagingControl(p => p.SetContainerCssClass("pagination"));
        }
    }

View Models

        [MetadataType(typeof(Employee_Metadata))]
        public partial class Employee
        {
            //Model properties defined in Northwind OData Reference
        }

        public class Employee_Metadata
        {
            [Required]
            public string LastName { get; set; }

            [Required]
            public string FirstName { get; set; }

            [Required]
            [RegularExpression(@"\(\d{2,3}\)\s\d{3}-\d{4}")]
            public string HomePhone { get; set; }
        }

Child Action

        public ActionResult ListEmployees(TableRequestModel request, bool readOnly = false)
        {
            var entities = new NorthwindEntities(NorthwindServiceUrl);
            return TableResult.From(entities.Employees).Build<EmployeeTable>(request);
        }