How to keep the first row open in a show/hide details scenario
How to keep the first row open in a show/hide details scenario
How do you keep the first row open when a page is reloaded?
I have a form within the detail area beneath each row. When the user click's the form's update button, i'd like to reload the page but keep the detail area open under just the first row. Below is the code I'm using to do the open/close stuff.
Thank you.
$(document).ready( function () {
/*
* Insert a 'details' column to the table
*/
var nCloneTh = document.createElement( 'th' );
var nCloneTd = document.createElement( 'td' );
nCloneTd.innerHTML = '';
nCloneTd.className = "center";
$('#example2 thead tr').each( function () {
this.insertBefore( nCloneTh, this.childNodes[0] );
} );
$('#example2 tbody tr').each( function () {
this.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] );
} );
var oTable = $('#example2').dataTable( {
"aoColumns" : [null, null, null, null, null, null,{"bVisible": false}, {"bVisible": false}, {"bVisible": false}, {"bVisible": false}, {"bVisible": false}, {"bVisible": false}, {"bVisible": false}, {"bVisible": false}], // need nine columns, include open/close column too
//"aoColumns" : [null, null, null, null, null, null, null, null, null, null, null, null, null, null], // need 14 columns, include open/close column too
"iDisplayLength": 10,
"aaSorting": [[ 3, "desc" ]],
"bJQueryUI": true,
//"sScrollY": "200px",
//"sScrollX": "100%",
"bScrollCollapse": true,
"bPaginate": true,
"sPaginationType": "full_numbers"
} );
$('#example2 tbody td img#openclose').live('click', function () {
var nTr = this.parentNode.parentNode;
if ( this.src.match('images/close.png') )
{
/* This row is already open - close it */
this.src = "images/open.png";
oTable.fnClose( nTr );
}
else
{
/* Open this row */
this.src = "images/close.png";
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
//make_jeditable ();
//make_cal_jeditable ();
//make_timezone_jeditable ();
check_form ();
updatephoto ();
}
} );
I have a form within the detail area beneath each row. When the user click's the form's update button, i'd like to reload the page but keep the detail area open under just the first row. Below is the code I'm using to do the open/close stuff.
Thank you.
$(document).ready( function () {
/*
* Insert a 'details' column to the table
*/
var nCloneTh = document.createElement( 'th' );
var nCloneTd = document.createElement( 'td' );
nCloneTd.innerHTML = '';
nCloneTd.className = "center";
$('#example2 thead tr').each( function () {
this.insertBefore( nCloneTh, this.childNodes[0] );
} );
$('#example2 tbody tr').each( function () {
this.insertBefore( nCloneTd.cloneNode( true ), this.childNodes[0] );
} );
var oTable = $('#example2').dataTable( {
"aoColumns" : [null, null, null, null, null, null,{"bVisible": false}, {"bVisible": false}, {"bVisible": false}, {"bVisible": false}, {"bVisible": false}, {"bVisible": false}, {"bVisible": false}, {"bVisible": false}], // need nine columns, include open/close column too
//"aoColumns" : [null, null, null, null, null, null, null, null, null, null, null, null, null, null], // need 14 columns, include open/close column too
"iDisplayLength": 10,
"aaSorting": [[ 3, "desc" ]],
"bJQueryUI": true,
//"sScrollY": "200px",
//"sScrollX": "100%",
"bScrollCollapse": true,
"bPaginate": true,
"sPaginationType": "full_numbers"
} );
$('#example2 tbody td img#openclose').live('click', function () {
var nTr = this.parentNode.parentNode;
if ( this.src.match('images/close.png') )
{
/* This row is already open - close it */
this.src = "images/open.png";
oTable.fnClose( nTr );
}
else
{
/* Open this row */
this.src = "images/close.png";
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
//make_jeditable ();
//make_cal_jeditable ();
//make_timezone_jeditable ();
check_form ();
updatephoto ();
}
} );
This discussion has been closed.
Replies
Something like this: http://datatables.net/table#row1
This would load the page with the first row in the open state.