1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-02-19 17:54:14 +01:00

Api: Column selector - jQuery selector as a string, an name selector

with :name postfix.

- Previously you could use a jQuery selector for columns by using the
  :jq postfix, and names were matched otherwise. This is reversed now
  for consistency with the rows and cells selectors which treat strings
  as jQuery selectors without the :jq postfix.
This commit is contained in:
Allan Jardine 2013-11-19 13:54:53 +00:00
parent e82068e7b3
commit 32e27fcc2f
2 changed files with 16 additions and 16 deletions

View File

@ -1 +1 @@
45379bfff91763dc2b7babbb90a7ecb037ffde3d
cc7a50b02dc22913382fd07c4524541bb8111d77

View File

@ -7648,15 +7648,15 @@
* "{integer}" - column index < 0 (count from right)
* "{integer}:visIdx" - visible column index (i.e. translate to column index)
* "{integer}:visible" - alias for {integer}:visIdx
* "{string}" - column name
* "{string}:jq" - jQuery selector on column header nodes
* "{string}:name" - column name
* "{string}" - jQuery selector on column header nodes
*
*/
// can be an array of these items, comma separated list, or an array of comma
// separated lists
var __re_column_selector = /^(.*):(jq|visIdx|visible)$/;
var __re_column_selector = /^(.*):(name|visIdx|visible)$/;
var __column_selector = function ( settings, selector, opts )
{
@ -7689,21 +7689,21 @@
// Visible index given, convert to column index
return [ _fnVisibleToColumnIndex( settings, parseInt( match[1], 10 ) ) ];
case 'jq':
// jQuery selector on the TH elements for the columns
return $( nodes )
.filter( match[1] )
.map( function () {
return $.inArray( this, nodes ); // `nodes` is column index complete and in order
} )
.toArray();
case 'name':
// match by name. `names` is column index complete and in order
return $.map( names, function (name, i) {
return name === match[1] ? i : null;
} );
}
}
else {
// match by name. `names` is column index complete and in order
return $.map( names, function (name, i) {
return name === s ? i : null;
} );
// jQuery selector on the TH elements for the columns
return $( nodes )
.filter( s )
.map( function () {
return $.inArray( this, nodes ); // `nodes` is column index complete and in order
} )
.toArray();
}
}
} );