Review
In the previous section, we have created the Java classes and discussed jqGrid's jsonReader format. In this section, we will focus on the presentation layer, in particular the HTML and JavaScript files.Table of Contents
Part 1: Introduction and Functional SpecsPart 2: Java classes
Part 3: HTML and jqGrid
Part 4: XML configuration
Part 5: Running the Application
Presentation Layer
To display our data without page-refresh and interactively, we will add AJAX and jqGrid, a jQuery plugin, to present tabular data.What is jQuery?
jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.
Source: http://jquery.com/
What is jqGrid?
jqGrid is an Ajax-enabled JavaScript control that provides solutions for representing and manipulating tabular data on the web. Since the grid is a client-side solution loading data dynamically through Ajax callbacks, it can be integrated with any server-side technology, including PHP, ASP, Java Servlets, JSP, ColdFusion, and Perl.
Source: http://www.trirand.com/jqgridwiki/doku.php
Preview
We only have a single HTML file (users.jsp, a JSP to be exact) to perform all actions. This page contains our jqGrid table and buttons for interacting with the data.Source
At first glance, when you look at the JavaScript code, it is somewhat intimidating, but once you've familiarized with the jqGrid syntax, you'll find that it's actually simple. If you aren't familiary with jqGrid, please visit the jqGrid Official WikiYou might be asking: "What's that humongous lines of jibberish code?" If you'd been following my blog, you would notice that I have tackled jqGrid a couple of times from my previous tutorials. If my explanation in this tutorial isn't enough, please see the following tutorials for an alternative perspective:
- Spring MVC: Integrating MySQL, MongoDB, RabbitMQ, and AJAX - Part 1: jQgrid View
- jqGrid and Spring 3 MVC Integration Tutorial
- Spring 3: Dynamic MVC using jqGrid and MongoDB
An In-depth Look
If we partition this HTML page, you will notice the following sections:- URL imports
- JavaScript and CSS imports
- jqGrid initialization
- JavaScript functions: addRow(), editRow(), deleteRow()
- HTML table
Notice how we've separated the HTML markup from the JavaScript code. We could, of course, move that one huge JavaScript code in an external js file, and make the HTML look somewhat smaller. But I'll leave that exercise to my readers.
Next
In the next section, we will focus on the configuration files for enabling Spring MVC. Click here to proceed.
Share the joy:
|
Subscribe by reader Subscribe by email Share
Thank you very much - it was helpful for me :-)
ReplyDeleteDear Krams
ReplyDeleteI have deployed this project on cloudfoundry , but when I access the url http://hamidspringjqrid.cloudfoundry.com/krams/crud it does not show the jqgid on the page instead show the plain json with i.e
{"total":"10","page":"1","records":"3","rows":[{"id":1,"firstName":"John","lastName":"Smith"},{"id":2,"firstName":"Jane","lastName":"Adams"},{"id":3,"firstName":"Jeff","lastName":"Mayer"}]}
So please help
Thank you
Have you tried deploying this on your local machine first? Did you get the same results?
ReplyDeleteDear Krams
ReplyDeleteYes , I have tried on localhost , it works fine , no problem , problem in deploying the project on the remote server http://hamidspringjqrid.cloudfoundry.com/krams/crud
So please help
Lot of thanks
krams: have you run into the bug with delete?
ReplyDeletehttp://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing
It looks like there could be an issue with an improper JS call to the "split" function on an array.
Error message when using form editing to do a delete is:
"Uncaught TypeError: Object 1 has no method 'split'"
Ever run into this?
@Anonymous, I have not encountered that so far. What version of jQuery and jqGrid are you using?
ReplyDeletejqGrid 4.3.1 and jQuery 1.7.1.
ReplyDeleteIt's still entirely possible (nay, likely) I'm doing something stupid, but I found it interesting to see other similar findings in the comments on the above link.
Krams, nice tutorial and I got it to run on my local machine under eclipse easily. However, I when I copied your jqgrid directories (js and css) to a new project, eclipse showed syntax errors in the jquery-1.6.4.min.js file - which it is not doing in your project! How did you set your project that this is not happening? Also, I notice this doesn't happen with your older jqgrid tutorial. Apparently the eclipse parser is out of date, but that doesn't explain why this project doesn't show errors.
ReplyDeleteThanks
Dave
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteSpring online training Spring online training Spring Hibernate online training Spring Hibernate online training Java online training
spring training in chennai spring hibernate training in chennai
Great Content. It will useful for knowledge seekers. Keep sharing your knowledge through this kind of article.
ReplyDeleteMVC Training in Chennai
MVC Classes in Chennai