key example inline editing gives error
key example inline editing gives error
ronald.wouters
Posts: 9Questions: 4Answers: 0
in Editor
Hi all
I am trying out the example in :
https://datatables.net/reference/event/key
Wheninline(cell)
is called I always get the following error:
Uncaught TypeError: Cannot read property 'contents' of undefined
Here is my code based on the example above:
var expensesDataTable = initOtherExpensesTable(); // KeyTable enabled
expensesDataTable.on('key', function (e, datatable, key, cell, originalEvent) {
if (key === 13) {
console.log('return key pressed');
expensesEditor
.one( 'close', function () {
expensesDataTable.keys.enable();
} )
.inline( cell );
expensesDataTable.keys.disable(); }
});
Here is the code causing the problem (last line of snippet below) :
this._edit(a, k, "inline", c, function() {
var a = e._formOptions(c);
if (!e._preopen("inline"))
return e;
var b = g.contents().detach();
Has anyone got this example working ?
Any ideas what might be wrong ?
Regards,
Ronald Wouters
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Hi @ronald.wouters ,
You could do something like this instead: http://live.datatables.net/rusiviyo/1/edit .
If that doesn't work, would you be able to modify that example to demonstrate the problem, please.
Cheers,
Colin
Hi @colin
the code in your example was in fact very similar to my starting point. The example code hower enables triggering inline editing on all columns. My requirements force me to trigger inline editing on some columns and bubble-editing on others. That is why I started looking at the "key" example.
Anyway, I modfied the example as you requested and it now produces the same error I get on my machine. You need to open the Chrome Dev Tools console however to fully see the error and the stacktrace.
Here is the updated example url:
http://live.datatables.net/rusiviyo/2/edit
Just for future reference, I am attaching a screenshot I just made here also (below).
Regards,
Ronald.
Hi,
The problem is that when you press return and open inline editing, it immediately starts listening for the return key itself. Which is still being processed, so it immediately submits and closes. You need a small delay to break that thread: http://live.datatables.net/mopipume/2/edit .
Allan
Hi @ronald.wouters ,
Just to note, I had to use a higher timeout,
10
was too short for me but100
works consistently. Also, note the value passed toinline()
, this has changed fro your example.Cheers,
Colin
I also used a timeout of 100 and it works. Thanks.
This means the original example should probably be updated to show the use of the timeout and the changed value passed to
inline()
because "my example" was just a copy/paste of the original with some name changes.Who takes care of that ?
Also, why was the line to disable keys commented out ?
That line was also present in the official "reference" example.
Regards,
Ronald
Me - I've done it already
C
It probably takes some time to show up then because when I look at the reference page with the example it still see the original value passed to
inline()
.Also the line to disable keys is still active and in the solution mentioned above it was commented out. Why was that ?
Regards,
Ronald
Yeah, pages only get updated when the website is rebuilt, which unfortunately doesn't happen too often. It's overdue a rebuild so will probably happen soon.
That was just a work-in-progress on the comment - I passed it onto Allan, in that state not expecting him to publish it. But yep, just make it active as in the original example.
C