DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Coding
  3. Languages
  4. Releasing Lib.AspNetCore.Mvc.JqGrid v1.0.0

Releasing Lib.AspNetCore.Mvc.JqGrid v1.0.0

Tired of trying to find the right library of his ASP.NET Core projects, a DZone MVB made his own. Read on to learn more about it!

Tomasz Pęczek user avatar by
Tomasz Pęczek
·
Apr. 18, 17 · Tutorial
Like (1)
Save
Tweet
Share
3.86K Views

Join the DZone community and get the full member experience.

Join For Free

A long time ago (according to the repository back in 2011) I made my 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 attributes and helpers, HSTS attributes or HTTP/2 Server Push with Cache Digest attributes and helpers had been added, but the 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 a 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 helpers, 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 helpers.
  • Lib.AspNetCore.Mvc.JqGrid.Helper - The strongly typed helper (a.k.a. the JavaScript generator).

The split was driven mostly by two use cases which have often been 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 case 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 the version for ASP.NET MVC was an independent class which needed to be initialized (typically in the view) and then 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 instances as parameters. 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 the 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 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 a Roadmap

This first version doesn't support all the features which Lib.Web.Mvc did. I've chosen the MVP based on what has been the most common subject for discussions and questions in the past. This gives the 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 a roadmap for subsequent releases. This is something that everybody can have their say on 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.

ASP.NET Core JavaScript ASP.NET ASP.NET MVC Use case application Requests Attribute (computing) HTML

Published at DZone with permission of Tomasz Pęczek. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Introduction Garbage Collection Java
  • Monolithic First
  • Scaling Your Testing Efforts With Cloud-Based Testing Tools
  • Java Concurrency: LockSupport

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: