This project is read-only.

This example application consists of three separate Visual Studio 2010 projects that are combined into one
solution as follows:

KoolGrid – This is the MVC web project that contains the Views and the Controllers. The Views will contain both JavaScript and HTML,
and the Controllers will interact with the Data Model and the business logic layer.

KoolMODEL - This project consists of the data entities that this application requires. The data model is separated
into its own library so it may be shared across the enterprise.

KoolBLL – The DLL class library will contain all the necessary business logic layer and data access code.

The Data Model (KoolMODEL)

Application development usually starts with defining your data entities and designing a database.
After building the database tables for this application, the following class was created that exposes the underlying data model:

Program Code


The Business Logic Layer (KoolBLL)

All interaction with the database and business logic is in a DLL library project which has classes that can be shared across different
applications across the corporate enterprise.

Program Code


Table Searching

This example application also includes a second HTML form demonstrating table search functionality that returns and builds an HTML grid that includes support for paging and sorting.

When hitting the SEARCH button in the View, the ScriptSearch method of the controller class is executed through an jQuery Ajax call. The business logic layer returns a generic list of table objects that are stored in the ViewData object. The ViewData object is the standard way of passing application data to the View.

Program Code


The paging functionality is controlled by passing in the values for the current page number and the page size. Only a single page of table objects is returned from the business
layer based on these two parameters. After the first page is rendered, the user can press the next page link which increments the current page number by one to get the
next set of records from the database.

In this example, a JSON object is not passed back to the View, This time, a partial view result is being returned. The goal is to dynamically generate a grid using a
MVC view user control named “ScriptSearchResults.ascx” as follows:

The view user control generates the needed HTML for the grid by iterating through the generic list of records in the ViewData Model object.
All this HTML is then passed back to the original JavaScript call.

When the HTML is returned from the view user control, the DIV tag inside the ScriptSearch.ascx” view user control is dynamically updated with the returned HTML.

Last edited Dec 12, 2011 at 4:02 AM by kalvin1dog, version 23


No comments yet.