Regex search and Natural Sort not working together

Regex search and Natural Sort not working together

butterchickenpiebutterchickenpie Posts: 3Questions: 1Answers: 0
edited July 2021 in Free community support

Hello,

When i use https://datatables.net/plug-ins/sorting/natural, it breaks regex search. This problem was raised in this discussion here - https://datatables.net/forums/discussion/27125 but it was closed.

The example here replicates this issue

live.datatables.net/lupufuci/2/

`// Works as expected. Search for "^A"

 var table = $('#example').DataTable({
   'search' : {'regex': true}
 });

If you now change the columns to use natural sort, the above will not work.

// Does not work expected. Search for "^A"
var table = $('#example').DataTable({
  'search'      : {'regex': true},
  'columnDefs'  : [{ type: 'natural', targets: '_all' }
                    ]     
});

In the original discussion there was a 'fix' by adding fn.dataTable.ext.type.search.natural to js. I may be adding it to the wrong place, i added that code to the natural.js but no luck. Can anyone shed some light

Answers

  • butterchickenpiebutterchickenpie Posts: 3Questions: 1Answers: 0

    ah, actually my use case was using natural-ci as the columndefs, if i use natural, then the fix does indeed work

  • butterchickenpiebutterchickenpie Posts: 3Questions: 1Answers: 0

    Right, i ended up just overriding natural to be case insensitive and that works for my use case :)

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Nice, glad it's all working,

    Colin

Sign In or Register to comment.