Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!
-
Recent Posts
Archives
Categories
Meta
Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!
I would suggest before getting started is to have some knowledge of the following. I wanted to first say thank you Phil Haack and his BLOG entry over at Haacked click here.
Here are a few steps to get a project started.
After you are done Site.Master file will look similar to this.
When it comes to the AdventureWorks database and setting it up I’m going to make the assumption that is not a challenge. I’m going to use the SalesOrderHeader table from the database to build the grid from. I’m going to create a Data layer in the web Application, a data context, and a repository to read the records from the database.
The ground work is in place now what we need to do is figure out what jqGrid does to get the data. This is where the documentation takes a dive. There is documentation on a URL you must setup for jqGrid to work. The is no explanation as to what parameters are passed to that URL and had to use those parameters to get the expected data. The only documentation that I have found that explains the parameters is here, but you need to scroll down to the prmNames section to see it. Another good example although not documentation, but you can see an explanation of the parameters in a PHP sample
From that we can see that a the page of data requested along with how may rows of data we need to get. These two parameters are called page and rows. Also being passed is the column to sort on and the direction to sort in. I will not get into sorting, but there are some good blog entries on how to implement that with dynamic LINQ (Thank you Phil). Now that we have the requirements down we need to build a method in our Sales Order Header Repository that will return paged data and only return a set number of records.
One of the blessing of using ASP.NET 3.x is the routing and method calling done before creating a web page. Knowing how the routing works we can use a URL in for jqGrid PlugIn that calls an Action inside a Controller. It should be easy to create a method knowing that the Action mimics the same named parameters of the URL. Pulling together this knowledge of the parameters used by jqGrid PlugIn and how the parameters for an Action works you can create Controller class with methods to handle the request of the jqGrid.
Now we need to use the repository to get the data based on the what is passed in and return the results as JSON. Let us start by looking at the requirements for the JSON results. You will see that a requirement is a count of total number of records.
There are many was to go about doing this, but for a quick and dirty way I’m just going to fulfill this requirement by adding a method to the repository that returns the total number of records. Later on this can become useful if there are filters applied then the method can be modified to count only the records base on a filter.
We can now build out the method in the controller now that we have all the supporting pieces.
I wont get into all the nuts and bolts of the logic you can take a look at the blogs mentioned above. Suffice to say that this will grab the data just the page of data from the database and return back a JSON Action Result.
The final piece to the puzzle is the HTML page. We will utilize the Content Placer we created in the Site.Master to hold the JavaScript. Some of the key options of the jqGrid PlugIn is the URL which is in the form of the default ASP.NET Routings which is /Controller/Action. You will also see that the data type is JSON. Finally and the most important one is the method type which is POST. With ASP.MVC 2 returning JSON results from a GET method type is not allowed by default because of security. Instead of use a GET as method to the call I changed it to use POST. I know the REST people are getting upset.
It is with hope that by stumbling through this and the other posts on the web you will be able to implement jqGrid PlugIn into ASP.NET MVC.
Pivot is now available to all who want to participate in the experiment. You can download it over at Get Pivot!
If you are in the Boston area on January 30th 2010 check out the SQLSaturday #34. Matt will be be doing some demos on Pivot.
Pivot Data Visualization
Live Labs recently released Pivot a tool to visualize data which can allow uses to see patterns in data like never before. In this session I will provide a basic intro to Pivot and discuss how to use you existing database and the Pivot Collection Tools SDK that I have released to dynamically build Pivot Collections.- Matt
One other possibility is that I’m using the logic wrong. The image list needs to be reorder into Morton Layout column major.
This is the test method
This is the output which looks identical to the control image in my previous post.
I got a bit side track on the TileBuilder because of a sorting issue that could be chalked up as a documentation error not a bug. I have my control images built for testing the expected layout of the TileBuilder. I built a series of images to represent the numbers from 0 to 24. I have also grouped the numbers into 3 groups, creating a 3 grids 4×4 each. I colored each group a different color as to stand out (Red, Green, Blue). I used the SeaDragon API to create a DZC as a reference point. In theory the TileBuilder logic should create the same results.
This is the control image built by SeaDragon API. This is Zoom Level 5 Row 0 Column 0. You can see the 4×4 groups in the various colors. You can also see (although a bit blurry) the Morton Layout.
And here is what I get with TileBuilder
Well I was correct that the pattern looks good but the expected out is not correct.