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.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs