1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-19 12:52:11 +01:00

Dev: Fix issue whereby you couldn't order with a click on a column after using order() API

Fix: I've removed the third entry in the aaSorting array, as the issue
was that after using order() that entry wasn't present. It was a bit
confusing as well, so it is now replaced with a property (_idx on the
aaSorting entries) which indicates the current sorting index (in
asSorting) - and this property is optional. If not given, it is looked
up or 0.
This commit is contained in:
Allan Jardine 2013-07-22 16:04:01 +01:00
parent 572e0ca9b9
commit de1ec231cd
2 changed files with 35 additions and 24 deletions

View File

@ -1 +1 @@
3a3d513eb3bee21daa9318ffd742c185bc9821a0
24512ff3401e29b83dd87a675626c71e4e5d97b6

View File

@ -506,7 +506,7 @@
*/
function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
{
var i, iLen, j, jLen, k, kLen;
var i, iLen, j, jLen, k, kLen, def;
// Column definitions with aTargets
if ( aoColDefs )
@ -514,8 +514,13 @@
/* Loop over the definitions array - loop in reverse so first instance has priority */
for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
{
def = aoColDefs[i];
/* Each definition can target multiple columns, as it is an array */
var aTargets = aoColDefs[i].targets || aoColDefs[i].aTargets;
var aTargets = def.targets !== undefined ?
def.targets :
def.aTargets;
if ( ! $.isArray( aTargets ) )
{
aTargets = [ aTargets ];
@ -532,12 +537,12 @@
}
/* Integer, basic index */
fn( aTargets[j], aoColDefs[i] );
fn( aTargets[j], def );
}
else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
{
/* Negative integer, right to left column counting */
fn( oSettings.aoColumns.length+aTargets[j], aoColDefs[i] );
fn( oSettings.aoColumns.length+aTargets[j], def );
}
else if ( typeof aTargets[j] === 'string' )
{
@ -547,7 +552,7 @@
if ( aTargets[j] == "_all" ||
$(oSettings.aoColumns[k].nTh).hasClass( aTargets[j] ) )
{
fn( k, aoColDefs[i] );
fn( k, def );
}
}
}
@ -6599,18 +6604,6 @@
} );
/**
* Get the DOM nodes for the `table` elements from the current API context.
* @return {DataTable.Api} New Api instance containing the DOM nodes for the
* tables.
*/
_Api.register( 'tables().nodes()', function () {
return this.iterator( 'table', function ( settings, i ) {
return settings.nTable;
} );
} );
_Api.register( 'table()', function ( selector ) {
var tables = this.tables( selector );
var ctx = tables.context;
@ -6624,13 +6617,31 @@
} );
_Api.register( 'table().node()', function () {
var ctx = this.context;
_Api.registerPlural( 'tables().nodes()', 'table().node()' , function () {
return this.iterator( 'table', function ( ctx ) {
return ctx.nTable;
} );
} );
if ( ctx.length ) {
return ctx[0].nTable;
}
// return undefined;
_Api.registerPlural( 'tables().body()', 'table().body()' , function () {
return this.iterator( 'table', function ( ctx ) {
return ctx.nTBody;
} );
} );
_Api.registerPlural( 'tables().head()', 'table().head()' , function () {
return this.iterator( 'table', function ( ctx ) {
return ctx.nTHead;
} );
} );
_Api.registerPlural( 'tables().foot()', 'table().foot()' , function () {
return this.iterator( 'table', function ( ctx ) {
return ctx.nTFoot;
} );
} );