mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-21 19:54:15 +01:00
Updated: server_side/row_details.html and api/row_details.html both now used live events to make life easier.
This commit is contained in:
parent
e4bed66535
commit
ba2db97c4d
@ -56,22 +56,20 @@
|
|||||||
* Note that the indicator for showing which row is open is not controlled by DataTables,
|
* Note that the indicator for showing which row is open is not controlled by DataTables,
|
||||||
* rather it is done here
|
* rather it is done here
|
||||||
*/
|
*/
|
||||||
$('td img', oTable.fnGetNodes() ).each( function () {
|
$('#example tbody td img').live('click', function () {
|
||||||
$(this).click( function () {
|
var nTr = this.parentNode.parentNode;
|
||||||
var nTr = this.parentNode.parentNode;
|
if ( this.src.match('details_close') )
|
||||||
if ( this.src.match('details_close') )
|
{
|
||||||
{
|
/* This row is already open - close it */
|
||||||
/* This row is already open - close it */
|
this.src = "../examples_support/details_open.png";
|
||||||
this.src = "../examples_support/details_open.png";
|
oTable.fnClose( nTr );
|
||||||
oTable.fnClose( nTr );
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
/* Open this row */
|
||||||
/* Open this row */
|
this.src = "../examples_support/details_close.png";
|
||||||
this.src = "../examples_support/details_close.png";
|
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
|
||||||
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
|
}
|
||||||
}
|
|
||||||
} );
|
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
</script>
|
</script>
|
||||||
@ -552,22 +550,20 @@ $(document).ready(function() {
|
|||||||
* Note that the indicator for showing which row is open is not controlled by DataTables,
|
* Note that the indicator for showing which row is open is not controlled by DataTables,
|
||||||
* rather it is done here
|
* rather it is done here
|
||||||
*/
|
*/
|
||||||
$('td img', oTable.fnGetNodes() ).each( function () {
|
$('#example tbody td img').live('click', function () {
|
||||||
$(this).click( function () {
|
var nTr = this.parentNode.parentNode;
|
||||||
var nTr = this.parentNode.parentNode;
|
if ( this.src.match('details_close') )
|
||||||
if ( this.src.match('details_close') )
|
{
|
||||||
{
|
/* This row is already open - close it */
|
||||||
/* This row is already open - close it */
|
this.src = "../examples_support/details_open.png";
|
||||||
this.src = "../examples_support/details_open.png";
|
oTable.fnClose( nTr );
|
||||||
oTable.fnClose( nTr );
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
/* Open this row */
|
||||||
/* Open this row */
|
this.src = "../examples_support/details_close.png";
|
||||||
this.src = "../examples_support/details_close.png";
|
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
|
||||||
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
|
}
|
||||||
}
|
|
||||||
} );
|
|
||||||
} );
|
} );
|
||||||
} );</pre>
|
} );</pre>
|
||||||
|
|
||||||
|
@ -27,28 +27,6 @@
|
|||||||
return sOut;
|
return sOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Event handler function */
|
|
||||||
function fnOpenClose ( oSettings )
|
|
||||||
{
|
|
||||||
$('td img', oTable.fnGetNodes() ).each( function () {
|
|
||||||
$(this).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(nTr), 'details' );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
oTable = $('#example').dataTable( {
|
oTable = $('#example').dataTable( {
|
||||||
"bProcessing": true,
|
"bProcessing": true,
|
||||||
@ -63,7 +41,22 @@
|
|||||||
{ "sClass": "center" }
|
{ "sClass": "center" }
|
||||||
],
|
],
|
||||||
"aaSorting": [[1, 'asc']],
|
"aaSorting": [[1, 'asc']],
|
||||||
"fnDrawCallback": fnOpenClose
|
} );
|
||||||
|
|
||||||
|
$('#example tbody td img').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(nTr), 'details' );
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
</script>
|
</script>
|
||||||
@ -126,28 +119,6 @@ function fnFormatDetails ( nTr )
|
|||||||
return sOut;
|
return sOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Event handler function */
|
|
||||||
function fnOpenClose ( oSettings )
|
|
||||||
{
|
|
||||||
$('td img', oTable.fnGetNodes() ).each( function () {
|
|
||||||
$(this).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(nTr), 'details' );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
oTable = $('#example').dataTable( {
|
oTable = $('#example').dataTable( {
|
||||||
"bProcessing": true,
|
"bProcessing": true,
|
||||||
@ -162,7 +133,22 @@ $(document).ready(function() {
|
|||||||
{ "sClass": "center" }
|
{ "sClass": "center" }
|
||||||
],
|
],
|
||||||
"aaSorting": [[1, 'asc']],
|
"aaSorting": [[1, 'asc']],
|
||||||
"fnDrawCallback": fnOpenClose
|
} );
|
||||||
|
|
||||||
|
$('#example tbody td img').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(nTr), 'details' );
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
} );</pre>
|
} );</pre>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user