Hysen Labs
Open-source project
robinvanderknaap/MvcJqGrid avatar
robinvanderknaap

MvcJqGrid

Fluent jqGrid Html Helper for ASP.NET MVC

100 stars71 forksC#LGPL-3.0
01
DEEP OPEN-SOURCE ANALYSIS

MvcJqGrid: jqGrid, fluent inside ASP.NET MVC views

MvcJqGrid is an HTML helper for ASP.NET MVC that brings jqGrid into your views through a fluent interface. Paging, sorting, and toolbar search are covered, with a modelbinder for the AJAX side.

02
DEEP OPEN-SOURCE ANALYSIS

What the helper takes on

jqGrid is a grid component, and MvcJqGrid is the wrapper that lets an ASP.NET MVC view configure it with method chaining instead of hand-written JavaScript. Most of the base properties, events, and methods are exposed, including paging, sorting, and toolbar searching. The README is upfront about what is not there yet: editing and subgrids are unsupported, and treegrids only basically.

03
DEEP OPEN-SOURCE ANALYSIS

From helper to rendered grid

The three pieces you need are jQuery, jqGrid, and the helper, all available through NuGet, with jQuery and jqGrid intentionally not bundled. The helper works with jqGrid 3.65 or later. In a view you call the grid in the Html class, the constructor's single argument sets the grid id, and everything else flows through chained methods whose order does not affect behavior. Once rendered, the grid fires an AJAX callback, and SetUrl points at a controller action that returns JSON or XML, with the response type controlled by SetDataType and JSON as the default.

04
DEEP OPEN-SOURCE ANALYSIS

The modelbinder and the demo project

The library ships a custom modelbinder that parses every parameter jqGrid sends and packs it into a strongly typed GridSettings object, which keeps controller actions tidy. The binder and the helper do not depend on each other, so you can bring your own. A sample application shows several grids with different configurations, and the view source sits under each grid in the page to make copying it easy, with a live version linked from the README.

06
DEEP OPEN-SOURCE ANALYSIS

Official sources

07
Community notes

Community notes