Releasing Lib.AspNetCore.Mvc.JqGrid v1.0.0
Long time ago (according to the repository back in 2011) I've made first version of Lib.Web.Mvc public. The initial functionality was a strongly typed helper for jqGrid. In later versions additional functionalities like Range Requests action result, CSP action attribute and helpers , HSTS attribute or HTTP/2 Server Push with Cache Digest attribute and helpers has been added, but jqGrid support still remained the biggest one. So when ASP.NET Core was getting closer to RTM this issue popped up. Now (14 months later) I'm releasing Lib.AspNetCore.Mvc.JqGrid version 1.0.0. As this is not just a port (I took the opportunity to redesign few things) I've decided to describe the key changes.
Packages organization
The functionality has been split into four packages:
- Lib.AspNetCore.Mvc.JqGrid.Infrastructure - Classes, enumerations and constants representing jqGrid options.
- Lib.AspNetCore.Mvc.JqGrid.Core - The core serialization and deserialization functionality. If you prefer to write your own JavaScript instead of using strongly typed helper, but you still want some support on the server side for requests and responses this is what you want.
- Lib.AspNetCore.Mvc.JqGrid.DataAnnotations - Custom data annotations which allow for providing additional metadata when working with strongly typed helper.
- Lib.AspNetCore.Mvc.JqGrid.Helper - The strongly typed helper (aka the JavaScript generator).
The split was driven mostly by two use cases which has been often raised. One is separating the (view) models from the rest of the application (for example independent assembly). The only package needed now in such cases is Lib.AspNetCore.Mvc.JqGrid.DataAnnotations which doesn't have any ties to ASP.NET Core. The second use cases is not using the JavaScript generation part, just the support in response and request serialization. That functionality has been separated as well in order to minimize footprint for such scenario.
Usage basics and demos
The helper in version for ASP.NET MVC was an independent class which needed to be initialized (typically in the view) and than could be used to generate the JavaScript and HTML (very similar to System.Web.Helpers.WebGrid). This has been changed, the JavaScript and HTML generation is exposed through IHtmlHelper
extensions methods (JqGridTableHtml
, JqGridPagerHtml
, JqGridHtml
, and JqGridJavaScript
) which take JqGridOptions
instance as parameter. This means that view code can be simplified to this (assuming all needed scripts and styles have been referenced):
@Html.JqGridHtml(gridOptions)
<script>
$(function () {
@Html.JqGridJavaScript(gridOptions)
});
</script>
The JqGridOptions
instance can be created anywhere in application, as it sits in Lib.AspNetCore.Mvc.JqGrid.Infrastructure there is even no reference to ASP.NET Core required. When it comes to the controller code, not much has changed. The Lib.AspNetCore.Mvc.JqGrid.Core provides classes like JqGridRequest
, JqGridResponse
or JqGridRecord
with appropriate binders and converters which are being automatically used.
public IActionResult Characters(JqGridRequest request)
{
...
JqGridResponse response = new JqGridResponse()
{
...
};
...
return new JqGridJsonResult(response);
}
There is a demo project available on GitHub which contains samples of key feature areas with and without helper usage.
Supported features and roadmap
This first version doesn't support all the features which Lib.Web.Mvc did, if I would want to achieve that I don't know when would I release. I've chosen the MVP based on what has been the most common subject for discussions and questions in the past. This gives following list of areas:
- Formatters
- Footer
- Paging
- Dynamic scrolling
- Sorting
- Single and advanced searching
- Form and cell editing
- Grouping
- Tree grid
- Subgrids
This is of course not the end. I will soon start setting roadmap for next releases. This is something that everybody can have their say about by creating or reacting to issues.
In general I'm open to any form of feedback (tweets, emails, issues, high fives, donations). I will keep working on this project as long as it will have value for anybody and I'll try to answer any questions.