Update jqGrid Html helper for ASP.NET MVC

We released a new version of MvcJqGrid, a fluent html helper which eases the the implementation of jqGrid in ASP.NET MVC applications. I'll give a short description of the most notable changes in this article. Source code and documentation are hosted on github. We included a sample application in the source code, a live example can be found here.

Razor engine support

Although it was possible to use the previous version with the razor engine, it wasn't quite obvious how. The following gives you a basic example how to use the new version of MvcJqGrid with the razor view engine:

@(Html.Grid("basic")
    .SetCaption("Basic Grid")
    .AddColumn(new Column("CustomerId")
        .SetLabel("Id"))
    .AddColumn(new Column("Name"))
    .AddColumn(new Column("Company"))
    .AddColumn(new Column("EmailAddress"))
    .AddColumn(new Column("Last Modified"))
    .AddColumn(new Column("Telephone"))
    .SetUrl("/Home/GridData/")
    .SetAutoWidth(true)
    .SetRowNum(10)
    .SetRowList(new int[]{10,15,20,50})
    .SetViewRecords(true)
    .SetPager("pager"))

NuGet

MvcJqGrid is now available as a NuGet package which makes installing the helper a trivial task:

install-package MvcJqGrid

You have to install jqGrid and jQuery yourself, we decided not to include these as dependencies.

Modelbinder

We included the jqGrid modelbinder created by Ilya Builuk. The modelbinder makes it easy to handle data requests from the grid in your controllers:

public JsonResult GridData(GridSettings gridSettings)
{
    ...
}

Sample Application

The sample application was also updated. The sample is included in the source code, you can find a live example here. The sample application is a nice way to get started with the helper, because for every sample grid the source code is displayed below the grid.

One word about the sample data being used. The sample data is contained in a Sql Express Database in the App_Data folder. Make sure you have installed Sql Server Express 2008 R2. The Web Platform Installer sometimes indicates you have installed R2 when actually you only have SP2 installed. More info on StackOverflow.

Unit tests

Daan le Duc went out of his way and added 129 unit tests to the project, which improved the overall quality of the Html Helper.

Hopefully, you'll like this new release. Suggestions, questions and comments are always welcome.

Share this article:

comments powered by Disqus