DataTables
DataTables Examples
HTML
<link rel="stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables.css">
<script src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables_themeroller.css "></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/jquery.dataTables.min.js"></script>
<div id="divButton">
<button class="toggle">Add Row</button>
</div>
</br>
<table id="table1">
<thead>
<tr>
<th>Rendering engine</th>
<th>Platform(s)</th>
<th>Engine version</th>
<th>CSS grade</th>
<th>CheckBox</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Win 95+</td>
<td>5.5</td>
<td>
<input type="text" class="txtBox"></input>
</td>
<td>
<input type="checkbox"></input>
</td>
</tr>
<tr>
<td>2</td>
<td>Win 98+</td>
<td>6</td>
<td>
<input type="text" class=" txtBox"></input>
</td>
<td>
<input type="checkbox"></input>
</td>
</tr>
<tr>
<td>3</td>
<td>Win XP SP2+</td>
<td>7</td>
<td>
<input type="text" class=" txtBox"></input>
</td>
<td>
<input type="checkbox"></input>
</td>
</tr>
</tbody>
</table>
CSS
.txtBox
{
background-color:red;
}
JavaScript
$(function () {
var tableOpts = {
"sPaginationType": "full_numbers",
"sScrollY": "150px",
"bFilter": false,
"fnCreatedRow": function (nRow, aData, iDataIndex) {
$(nRow).attr('id', aData[0]);
var txtBox = $(nRow).find("input[type=text]");
txtBox.attr('id', 'text-' + aData[0]);
var checkBox = $(nRow).find("input[type=checkbox]");
checkBox.attr('id', 'check-' + aData[0]);
}
}
var table1 = $('#table1').dataTable(tableOpts);
$('#divButton').find('.toggle').on('click', function () {
table1.fnAddData([4, 'Windows 7',7.1]);
});
});