Giter Club home page Giter Club logo

mvctables's Introduction

MvcTables

![Gitter](https://badges.gitter.im/Join Chat.svg)

An AJAX/HTML Table framework for ASP.Net MVC

Supports:

  • paging,
  • sorting,
  • filtering,
  • MVC Edit/Display templates for cell markup,
  • Partial Views for cell markup,
  • HtmlHelper style column configuration
  • Fluent configuration

Nuget Here

Example Here

Blog Article

Configuration

To save loads of messy boiler plate code clogging up Controller actions, the tables can be configured at startup. Any class that inherits TableConfigurator<TType> can be registered int the global.asax thusly:

Global.asax
```C# public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { //Regular MVC Setup hoo haa ConfigureMvcTables.InTheSameAssembly.As(); } } ```
Usage - Action Method
```C# public ActionResult ListEmployees(TableRequestModel request) { var entities = new NorthwindEntities.NorthwindEntities(NorthwindServiceUrl); return new TableResult(entities.Employees, request); } ```
Auto Configuration
```C# public class CategoryTable : MvcTable { public override void Configure(ITableConfiguration config) { config .SetCssClass("table table-striped") .ScaffoldAllColumns(); } } ```
Basic Configuration
```C# public class InvoiceTable : MvcTable { public override void Configure(ITableConfiguration config) { config .SetCssClass("table table-striped") .DisplayForColumn(m => m.ProductName) .DisplayForColumn(m => m.Quantity) .DisplayForColumn(m => m.Region) .DisplayForColumn(m => m.Salesperson) .EditorForColumn(m => m.Discount); } } ```
More Complex Configuration
```C# public class OrderDetailTable : MvcTable { public override void Configure(ITableConfiguration config) { config .SetCssClass("table table-striped") .ConfigurePagingControl(p => p.ShowPagingControl(true)) .DisplayForColumn(c => c.Product.ProductName, cfg => cfg.DefineFooter((h, rows) => rows.Any() ? "Order ID: " + rows.First().OrderID : "")) .DisplayForColumn(c => c.Quantity) .DisplayForColumn(c => c.UnitPrice) .DisplayForColumn(c => c.LineTotal, cfg => cfg.DefineFooter((h,rows) => rows.Any() ? rows.Sum(od => od.LineTotal).ToString("c") : "")) .ConfigurePagingControl(p => p.ShowPagingControl(false)) .SetFilterSelector("childFilter");
        SetName("ChildOrderDetails");
    }
}
<dl>
  <dt>Runtime Configuration Overrides - Action Method</dt>
  <dd></dd>
</dl>
```C#
    public ActionResult ListEmployees(TableRequestModel request)
    {
        var entities = new NorthwindEntities.NorthwindEntities(NorthwindServiceUrl);
        
        var result = new TableResult<Employee>(entities.Employees, request);
        
        // Override configuration
        result.Overrides.EditorForColumn(d => d.HireDate, cfg => cfg.SetIndex(1));
        return result;
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.