我正在使用datatables插件和当前代码我已展开/折叠当td中的图像被点击,但我想能够点击行来展开请任何人都可以帮助这个?下面是代码:Datatables jquery展开/折叠和动画
$(document).ready(function() {
/*
* Insert a 'details' column to the table
*/
var nCloneTh = document.createElement('th');
var nCloneTd = document.createElement('td');
nCloneTd.innerHTML = '<img src="../examples_support/details_open.png">';
nCloneTd.className = "center";
$('#example thead tr').each(function() {
this.insertBefore(nCloneTh, this.childNodes[0]);
});
$('#example tbody tr').each(function() {
this.insertBefore( nCloneTd.cloneNode(true), this.childNodes[0]);
});
/*
* Initialse DataTables, with no sorting on the 'details' column
*/
var oTable = $('#example').dataTable({
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] }
],
"aaSorting": [[1, 'asc']]
});
/* Add event listener for opening and closing details
* Note that the indicator for showing which row is open is not controlled by DataTables,
* rather it is done here
*/
$('#example tbody td').live('click', function() {
var nTr = this.parentNode.parentNode;
if (this.src.match('details_close'))
{
/* This row is already open - close it */
this.src = "../examples_support/details_open.png";
oTable.fnClose(nTr);
}
else
{
/* Open this row */
this.src = "../examples_support/details_close.png";
oTable.fnOpen(nTr, fnFormatDetails(oTable, nTr), 'details');
}
});
});
其次,我想展开和折叠成为一个平滑的动画有人能告诉我该怎么做?
感谢
可你把它变成的jsfiddle所以我们可以看到你想什么呢? – 2011-06-10 15:40:16