Has something fundamental changed with the new version of Editor? I can't use complex keys anymore.
Has something fundamental changed with the new version of Editor? I can't use complex keys anymore.
With the conversion to Editor 1.5, I am unable to edit any rows. I get errors like:
Uncaught Error: Syntax error, unrecognized expression: #{"P":""
{"P":""
in this case is a value of DT_RowId. This worked perfectly prior to 1.5.
This error comes from Sizzle, which JQuery uses for selectors. This to me suggests that Editor 1.5 is somehow using the value in a selector, e.g. if DT_RowId's value is "abc123", then we get $( "#abc123" ).DoSomething();
.
If this is true, I can't use Editor 1.5. My application needs to have keys that wouldn't be valid DOM IDs.
I'm using arrays (idSrc: 0
) to send the data, though I doubt this is the problem. I have another, simpler form which uses Editor 1.5 with arrays. It works fine, but its first column value is numeric.
AJAX Load:
{
"draw" : 1,
"recordsTotal" : 3,
"recordsFiltered" : 3,
"data" : [
[
"{\"P\":\"AAAX88AAJAAAAGXAAA\",\"K\":{\"ID\":1}}",
1,
"Administrator",
"TableMan Administrators-1"
],
[
"{\"P\":\"AAAX88AAJAAAAGXAAB\",\"K\":{\"ID\":2}}",
2,
"Test Group2",
"Includes a few more tables"
],
[
"{\"P\":\"AAAX88AAJAAAAGXAAC\",\"K\":{\"ID\":3}}",
3,
"3rd Groupx2",
"Includes yet more tables"
]
]
}
Request:
{
"action" : "edit",
"data" : {
"{\"P\":\"\",\"K\":{\"Id\":4}}" : {
"EditorId" : "-6",
"AccountId" : "1",
"EventType" : "L",
"LogSqlId" : "0",
"LogIpAddressId" : "1",
"UtcTime" : "09/02/2015 4:59 PM"
}
}
}
Response:
{
"data" :
[
[
"{\"P\":\"\",\"K\":{\"Id\":4}}",
4,
-6,
1,
"L",
0,
1,
"2015-09-02T16:59:00"
]
]
}
Chrome's trace (at least, it looks like a trace to me):
Uncaught Error: Syntax error, unrecognized expression: #{"P":""
Sizzle.error @ jquery-2.1.4.js:1458
Sizzle.tokenize @ jquery-2.1.4.js:2075
Sizzle.compile @ jquery-2.1.4.js:2446
Sizzle.select @ jquery-2.1.4.js:2536
Sizzle @ jquery-2.1.4.js:855
Sizzle.matches @ jquery-2.1.4.js:1396
jQuery.filter @ jquery-2.1.4.js:2672
winnow @ jquery-2.1.4.js:2655
jQuery.fn.extend.filter @ jquery-2.1.4.js:2704
(anonymous function) @ tm.min.js:175Za @ tm.min.js:172
(anonymous function) @ tm.min.js:174
h.extend.iterator @ tm.min.js:162
(anonymous function) @ tm.min.js:174
t.extend.g @ tm.min.js:165
(anonymous function) @ tm.min.js:178
t.extend.g @ tm.min.js:165
E.dataTable.commit @ tm.min.js:424
f._dataSource @ tm.min.js:402
(anonymous function) @ tm.min.js:415
(anonymous function) @ Editor?id=9:83
jQuery.Callbacks.fire @ jquery-2.1.4.js:3099
jQuery.Callbacks.self.fireWith @ jquery-2.1.4.js:3211
done @ jquery-2.1.4.js:8264
jQuery.ajaxTransport.options.send.callback @ jquery-2.1.4.js:8605
browserLink:37 XHR finished loading: GET "http://localhost:61071/dc7f0afe6d5c4ba592d097da5a0d5fca/arterySignalR/ping?…KHTML%2C+like+Gecko)+Chrome%2F45.0.2454.85+Safari%2F537.36&_=1442619094666".p.support.ajax.p.ajaxTransport.c.send @ browserLink:37p.extend.ajax @ browserLink:37i.transports._logic.pingServer @ browserLink:62(anonymous function) @ browserLink:62
I'll send the DataTables Debug bookmarklet results elsewhere.
I've been at this for over a week, and have raised the white flag. I would really appreciate any ideas.
This question has an accepted answers - jump to answer
Answers
Hi,
Thanks for posting this and all of the details! It is interesting that an error is occurring in the
commit
function (line 18 of your trace above) and not in theedit
function that Editor uses, which executes similar code.As a little workaround for the moment, could you try the following - in the
dataTables.editor.js
file find:And replace with:
That will cause the code to drop down into the slower, but, in this case, more accurate row finding loop.
What is really interesting is that jQuery's selectors shouldn't actually be getting invoked at all here with the latest DataTables versions.
I'll create a local test case to try and diagnose the issue fully.
Allan
I've realised why this isn't entering DataTables' optimised ID code and thus avoiding the issue with the jQuery selector not being valid - specifically DataTables doesn't "know" what piece of information to use as the row id (
rowId
in the new versions - 1.10.8+). Therefore it falls into the jQuery selector. You could try addingrowId: 0
to your DataTables initialisation.Allan
Thanks for the workaround code, Allan. I haven't tried it yet since I am using a single, minified file from the awesome new DataTables Downloader.
The error still occurs when I add
rowId
to the DataTables initialization.Once I get back to this project I'll try base64 encoding the rowid data. I wanted to avoid that for space reasons, but it'll likely be a wash with all the escape characters needed for quotation marks, and zip usually does a good job of compressing base64 to just over the compressed size of the original data.
Base64 encoding the first row of data was a success.