Rewriting the MvcContrib Grid
February 8, 2009 – 2:47 pm
This is part 1 of a series on the new MvcContrib grid component.
- Part 1 – Introduction
- Part 2 – New Syntax
- Part 3 – GridModels and GridRenderes
- Part 4 – Limitations of the WebFormsViewEngine
- Part 5 – The Action Syntax
Over the next couple of weeks I’m hoping to write a few posts on the upgrades I’m doing to the MvcContrib grid component. These are the features that I’m planning on adding:
A Fluent Interface
Like the HTML-helpers built into the ASP.NET MVC framework, the mvccontrib grid suffers from ‘overload hell’. Switching to a fluent interface should provide a cleaner and more discoverable API.
Discouraging logic in Views
One side effect of the fluent interface is that it will no longer be possible to use the grid’s section overrides. However, I consider this to be a good thing. Embedding custom sections makes it all to easy to get stuck in ‘tag soup’. To make up for this, the new grid will support rendering partials for custom sections.
Reusable Grid Models
The new grid will support reusable grid definitions. That is, you will be able to define a grid in a external class and then reference this from your views. One benefit of this approach is that it means the grid will finally be accessible to VB users. The current grid is C#-only due to its use of lambda-statements for defining columns.
Customisable Grid Rendering
The existing grid only supports rendering in an HTML table. This means that if you wanted to render a grid in a different format (for example, as an OpenXML Spreadsheet) it meant you needed to inherit from the Grid class, override several methods and then create a new helper. The new grid will allow a custom GridRenderer class to be provided in the grid definition. Rendering as an HTML table will still be the default behaviour.
Separate Pagination Component
The current grid has built in support for paging. With the new grid, this will be moved into a separate component.
Sorting
Time permitting, the new grid will have support for sorting.
In my next post I’ll focus on the grid’s Fluent Interface.
9 Responses
Great cant wait for this, I am currently investing the best ways to render a schedule control similar to google calendar and will watch out for your posts.
Look forward to helping out with this.
[...] interface that provides a cleaner and more discoverable API. You can read all details from Jeremy Skinner’s blog about the new enhancements of MVCContrib Grid helper component. I am creating the T4 template [...]
[...] http://www.jeremyskinner.co.uk/2009/02/08/rewriting-the-mvccontrib-grid/ [...]
[...] http://www.jeremyskinner.co.uk/2009/02/08/rewriting-the-mvccontrib-grid/ [...]
I published my Pager MVC control without requiring a collection to implement IPagination interface.
More info at: http://fknet.wordpress.com/2009/03/05/aspnet-mvc-pager/
Sorting, Sorting, Sorting, please, Sorting, Sorting, Sorting, Sorting, please.
It is must for my current project.
@Dario-g,
There are a couple of options for sorting. If you want clientside sorting then check out the jQuery datatable plugin or sorttable. If you want serverside sorting then I committed a patch the other day that enables this.
Jeremy
[...] Ausgabe verwendet wird, beliebig anpassen. (Standardmäßig wird hier eine Html-Tabelle verwendet.) Hier findet sich eine kurze Einführung in die verschiedenen [...]