Error initialization DataTable

Error initialization DataTable

chavdarkchavdark Posts: 2Questions: 1Answers: 0

Hi,
DataTables 1.12.0
Chrome 101.0.4951.67

I am getting error on inititalization of the DataTable.
The error is on line 15301. Cannot read properties of undefined (reading 'value')

// Based on locale, determine standard number formatting
var __thousands = '';
var __decimal = '';

if (Intl) {
    var num = new Intl.NumberFormat().formatToParts(1000.1);

    __thousands = num[1].value;
    __decimal = num[3].value;
}

I am using latest version of Chrome.
May be the result is not start from index 1, because if I change index to 0 and 1 this works correclty.
// Based on locale, determine standard number formatting
var __thousands = '';
var __decimal = '';

if (Intl) {
    var num = new Intl.NumberFormat().formatToParts(1000.1);

    __thousands = num[0].value;
    __decimal = num[2].value;
}

Answers

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,770

    Without seeing the problem its hard to say. Sounds like you need to debug the num value to find where the undefined is coming from. From the code posted it doesn't seem to be anything specific with Datatables but with your data and this statement:

    var num = new Intl.NumberFormat().formatToParts(1000.1);
    

    If you still need help please provide a link to your page or a test case replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • chavdarkchavdark Posts: 2Questions: 1Answers: 0

    The problem is with different culture.

    var num = new Intl.NumberFormat().formatToParts(1000.1);
    alert(num[0].value);
    alert(num[1].value);
    alert(num[2].value);
    alert(num[3].value);

    On English Culture num[0].value Is "1", num[1].value is ",", num[2].value is "000" and num[3].value is "."
    On Bulgarian culture num[0].value Is "1000", num[1].value is "," and num[2].value is "1". There is no num[3].

    The error is in jquery.dataTables.js on line 15301 where the num[3].value is used.

  • crisleiriacrisleiria Posts: 2Questions: 0Answers: 0

    Hi all,

    Same problem here. Just update to datatables 1.12
    Uncaught TypeError: Cannot read properties of undefined (reading 'value')
    on this line: __decimal = num[3].value;

  • crisleiriacrisleiria Posts: 2Questions: 0Answers: 0

    Quick update,

    downgrade to 1.11.3 fixed the problem.

  • allanallan Posts: 61,726Questions: 1Answers: 10,110 Site admin

    Apologies - this is an error in DataTables 1.12.0. It is fixed in the nightly and we'll be doing a 1.12.1 release, probably tomorrow, with the fix.

    Allan

Sign In or Register to comment.