error when using currency type detection plugin

error when using currency type detection plugin

car_lostcar_lost Posts: 1Questions: 0Answers: 0
edited March 2014 in General
I am having an issue similar to the one reported in this post: http://www.datatables.net/forums/discussion/11168/sorting-currency/p1

>> Uncaught TypeError: Object # has no method '_fnEscapeRegex'

Using
jQuery 1.9.1
DataTables 1.9.4
Chrome 33
OSX 10.7.5

As per the type detection documentation:

[quote]To use of one of the plug-in type detections functions below, you simply need to include it and its counterpart sorting function, in the Javascript available for your page, after you load the DataTables library, but before you initialise the DataTable.
[/quote]

Order of ops:
- load jQuery source
- load DataTable source
- load currency type detection (https://datatables.net/plug-ins/type-detection) and then sort (https://datatables.net/plug-ins/sorting) plugin source
- initialize the datatable

The problem appears to be in the following line of the currency detection plugin:

[code]// Init the regex just once for speed - it is "closure locked"
var
str = jQuery.fn.dataTableExt.oApi._fnEscapeRegex(validChars),
re = new RegExp('[^'+str+']');
[/code]

The function _fnEscapeRegex and the rest of the functions that constitute oApi, are not added to oApi until the DataTable is initialized. When the currency type detection plugin source is loaded the closure is executed. This closure executes an oApi method, which as this point does not exist.

Once i removed this method and escaped the string literal, the plugins worked just fine.

I have looked at the documentation. However, I can't fine a place where the type detection & sorting plugins can take advantage of the oApi.

Carlos

Replies

  • socialinksocialink Posts: 5Questions: 2Answers: 0
    edited April 2014
    Carlos, what was the final full code of the type detection? I'm still getting a ton of errors. Thanks!
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    Try using v1.10 - it has currency sorting built in.

    Allan
  • socialinksocialink Posts: 5Questions: 2Answers: 0

    Thanks Allan!

This discussion has been closed.