GridTable - jQuery
by rajeshpillai
HTML
<div id="debug"></div>
<div>
<h2>DATATABLE DEMO </h2>
</div>
<table id = "foo">
<thead>
<tr>
<th>Sr. No</th>
<th>Skills</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>C#</td>
</tr>
<tr>
<td>2</td>
<td>JavaScript</td>
</tr>
<tr>
<td>1</td>
<td>C#</td>
</tr>
<tr>
<td>2</td>
<td>JavaScript</td>
</tr>
<tr>
<td>1</td>
<td>C#</td>
</tr>
<tr>
<td>2</td>
<td>JavaScript</td>
</tr>
<tr>
<td>1</td>
<td>C#</td>
</tr>
<tr>
<td>2</td>
<td>JavaScript</td>
</tr>
</tbody>
</table>
CSS
/*
OpenJS Grid
Copyright (c) 2011 Sean Clark, http://square-bracket.com
http://youtube.com/optikalefxx
http://square-bracket.com/openjs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This is OpenJS Grid version 1.8
Style Theme: Node
*/
/*********************************************************************************/
/*********************************************************************************/
/***************************** COLORS *********************************/
/*********************************************************************************/
/*********************************************************************************/
/* main color */
.gridContainer {
padding:20px;
background-color: #222;
background-image: -webkit-gradient(linear, left top, left bottom, from(#222), to(#333));
background-image: -webkit-linear-gradient(top, #222, #333);
background-image: -moz-linear-gradient(top, #222, #333);
background-image: ...
JavaScript
$(function() {
UxTable("foo").dataTable({"width":"350",
"height":"100",
"title":"JAVASCRIPT DATATABLE PLUGIN"});
});
function UxTable(ele) {
this.defaults = {
width: "300",
height: "350",
title: "Title"
};
this.th = null;
this.tb = null;
if (this === window) {
return new UxTable(ele);
}
var type = typeof ele;
if (type === "string") {
this.element = document.getElementById(ele);
}
else if (type === "object" &&
ele.nodeType !== "undefined" &&
ele.nodeType === 1) {
this.element = ele;
}
else {
throw new Error("Argument is of wrong type");
}
this.dataTable = function (options) {
if (options !== "undefined" && options !== null) {
this.defaults.width = options.width;
this.defaults.height = options.height;
this.defaults.title = options.title;
}
var parent = this.element.parentNode;
// Get the head element. getElmentsByTagName returns an array.
var thead = this.element.getElementsByTagName("thead");
// Grab the first head element (ideally a table should have only one head)
var clone = thead[0];
// Get the table tbody element
var tbody = this.element.getElementsByTagName("tbody");
// Create a grid/table container
var gridContainer = document.createElement("div");
gridContainer.setAttribute("class","gridContainer");
parent.insertBefore(gridContainer, this.element);
// Create a wrapper div element
var gridHeader= document.createElement("div");
// Set the class attribute
gridHeader.setAttribute("class", "table-header");
// Insert the div before the current element (table)
...