≡

UUIDs not working as row ids in DataTables 3

UUIDs not working as row ids in DataTables 3

bg7bg7 Posts: 135Questions: 21Answers: 0

A while back I upgraded from DataTables 1 to 2 and ran into issues with row ids and escaping those strings. Allan and Kevin, you guys kindly helped sort through those issues.

https://datatables.net/forums/discussion/81238/inconsistent-results-looking-up-rows-by-unescaped-and-escaped-rowid-in-datatables-2-x-but-not-1-x#latest

The end result involved switching over to use UUIDs for all our row ids. I'm now in the process of upgrading to DataTables 3 and I'm running into problems using those UUIDs as row ids.

According to the documentation here:

https://datatables.net/ref/core/type/DataTable.RowSelector#string---#ID

it says:

"Unlike CSS this value does not need to be escaped"

Unfortunately that doesn't seem to be the behavior I'm seeing now. Instead I'm getting errors like this:

In the code it looks like it's trying to use it as a CSS selector (which won't work because it starts with a number):

Also, I was playing around with those row lookups in the console and discovered that '#0' seems to look up row 0 which was unexpected as I figured it would fail as well but apparently not. Using other numbers, e.g. '#00' and '#1', throw errors.

I'm not sure if I'm missing something or using the API incorrectly or if this is a DataTables bug. Any advice would be appreciated.

Thanks.

Ben

Answers

  • kthorngrenkthorngren Posts: 22,509Questions: 26Answers: 5,172

    Using UUID's works in this test case:
    https://live.datatables.net/gujocipi/1/edit

    Note the row id property used is id and is defined using rowId. If you remove the rowId option then you will see the same error, for example:

    dataTables.js:2362 Uncaught SyntaxError: Failed to execute 'matches' on 'Element': '#550e8400-e29b-41d4-a716-446655440002' is not a valid

    If you aren't using the DT_RowId property, which is the default Datatables looks for, then you will need to define the property using rowId.

    If this doesn't help then please provide a test case showing the issue.

    Kevin

  • allanallan Posts: 66,119Questions: 1Answers: 11,021 Site admin

    Something must be running the uuid through filter() as a DOM selector. @bg7 are you able to link to a test case showing the issue so I can track it down?

    Allan

Sign In or Register to comment.