DEV Community

Robin van der Knaap
Robin van der Knaap

Posted on • Originally published at Medium on

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"))
view raw gistfile1.cs hosted with ❤ by GitHub

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)
{
...
}
view raw gistfile1.cs hosted with ❤ by GitHub

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.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay