GridView in Jquery. (DataTable)

In web application gridview is very important part to show data in table format. A grid view or a datagrid is a graphical user interface element (widget) that presents a tabular view of data.

DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table. Key features:

Setting up DataTables

The first step is to obtain the library from the DataTables website. 1.9.4 is the current stable version and 1.10 is in development now. If you don’t want to download the files, you can also make use of theMicrosoft CDN. As it is a jQuery plugin you should include the jQuery library too, preferably the latest version.

Leats start..

DataTables can work with data from a verity of sources. It can directly work on an HTML table or we can specify data as an array while initialization. Or it can work on data coming from an Ajax source.

In this article we’ll create a listing of websites in the SitePoint network. We’ll start with the listing of a few site names, and then we’ll add more columns and features. Here we have an HTML table with one column that lists the names of just three sites. Let’s see what DataTables can do with a minimal setup.

</pre>
<html>
<head>
 	<link rel="stylesheet" type="text/<span class=" />css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
</head>
<body>
 Myexample">
<table id="<span class="></table>
 <thead>
 <tr><th>Name</th>
 <th>Technology</th>
 <th>Site</th></tr>
 </thead>
 <tbody>
 <tr><td>Pradeep</td>
 <td>.NET</td>
 <td>www.asp.net</td></tr>
 <tr><td>Preet</td>
 <td>Jquery</td>
 <td>www.jquery.com</td></tr>
 <tr><td>Atkari</td>
 <td>MVC</td>
 <td>www.asp.com/mvc</td></tr>
 </tbody>
 </table>
<script type="text/<span class=">// <![CDATA[
javascript</span>" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js">
// ]]></script>
<script type="text/<span class=">// <![CDATA[
javascript</span>" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js">
// ]]></script>
 <script>
 $(function(){
 $("#Myexample").dataTable();
 })
 </script>
</body>
</html>
<pre>
Screen Out Put:-
Screen out put
DataTable view instate of GridView.

You can try this code by yourself, just copy paste that HTML code and paste in notepad. save as .html after saving open that file in web browser (make script enable). that’s is you done and enjoy the view.

You can do everything with DataTable whatever you can do with GridView or much more than.

you can use array, serverside data fetching, sorting, searching, readonly column, runtime field editing and much more.

this is only brief introduction about datatable and you can find much more with datatable officially site. Its grate tool for web application.