Skip to content

Commit

Permalink
62de69f5139683e67d10cd30b43cc4a860bf2bb8 Updated: The :visible colu…
Browse files Browse the repository at this point in the history
…mn selector can now have a DOM selector in front of it to select visible columns based on the selector given.

Sync to source repo @62de69f5139683e67d10cd30b43cc4a860bf2bb8
  • Loading branch information
dtbuild committed Aug 15, 2024
1 parent 8750dca commit d6342f3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
2 changes: 1 addition & 1 deletion datatables.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
],
"src-repo": "http://github.com/DataTables/DataTablesSrc",
"last-tag": "2.1.3",
"last-sync": "dd8627378442bf4a2d6f6c33328bb04dc4b90607"
"last-sync": "62de69f5139683e67d10cd30b43cc4a860bf2bb8"
}
20 changes: 16 additions & 4 deletions js/dataTables.js
Original file line number Diff line number Diff line change
Expand Up @@ -8482,8 +8482,10 @@
switch( match[2] ) {
case 'visIdx':
case 'visible':
if (match[1]) {
// Selector is a column index
if (match[1] && match[1].match(/^\d+$/)) {
var idx = parseInt( match[1], 10 );

// Visible index given, convert to column index
if ( idx < 0 ) {
// Counting from the right
Expand All @@ -8496,9 +8498,19 @@
return [ _fnVisibleToColumnIndex( settings, idx ) ];
}

// `:visible` on its own
return columns.map( function (col, i) {
return col.bVisible ? i : null;
return columns.map( function (col, idx) {
// Not visible, can't match
if (! col.bVisible) {
return null;
}

// Selector
if (match[1]) {
return $(nodes[idx]).filter(match[1]).length > 0 ? idx : null;
}

// `:visible` on its own
return idx;
} );

case 'name':
Expand Down
2 changes: 1 addition & 1 deletion js/dataTables.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dataTables.min.mjs

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions js/dataTables.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8429,8 +8429,10 @@ var __column_selector = function ( settings, selector, opts )
switch( match[2] ) {
case 'visIdx':
case 'visible':
if (match[1]) {
// Selector is a column index
if (match[1] && match[1].match(/^\d+$/)) {
var idx = parseInt( match[1], 10 );

// Visible index given, convert to column index
if ( idx < 0 ) {
// Counting from the right
Expand All @@ -8443,9 +8445,19 @@ var __column_selector = function ( settings, selector, opts )
return [ _fnVisibleToColumnIndex( settings, idx ) ];
}

// `:visible` on its own
return columns.map( function (col, i) {
return col.bVisible ? i : null;
return columns.map( function (col, idx) {
// Not visible, can't match
if (! col.bVisible) {
return null;
}

// Selector
if (match[1]) {
return $(nodes[idx]).filter(match[1]).length > 0 ? idx : null;
}

// `:visible` on its own
return idx;
} );

case 'name':
Expand Down

0 comments on commit d6342f3

Please sign in to comment.