Editor 3 doesn't activate, but Editor 2 works flawlessly with the exact same code
Editor 3 doesn't activate, but Editor 2 works flawlessly with the exact same code
Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
None
Description of problem:
We're in the process of updating to DT3 including Editor 3. The current status is that we are able to use DT3 with our code as expected. But the when function editor.inline( this ) is called when a user selects a row for editing doesn't lead to anything, not even an error message.
The Editor is initiated with this code:
editor = new DataTable.Editor( {
table: '#' + domId,
fields: dtData.fields ? dtData.fields : dtData.columns.map( col => ( { label: col.title, name: col.data, variable: col.type } ) ),
formOptions: { inline: { submit: 'changed' } },
idSrc: dtData.idSrc ?? dtData.rowId,
} );
And the inline function is called like this:
targetTable.on( 'dblclick', 'tbody td', function ( event ) {
event.preventDefault();
if ( event.currentTarget.className.includes( 'editable' ) )
editor.inline( this, { submit: dtData.logicSource === 'events' ? 'all' : 'changed' } );
} );
The callback does get called, including the editor.inline function, but then nothing more happens.
When reverting back to DT2.3.8/Editor 2 everything works again.
I've currently not tried to create a test case for this, will try to do that later if needed.
Answers
Interesting, thanks for posting this. I would have expected that to work, given how similar it is to this example.
Is
thisthetdcell in the event handler?If you are able to create a test case, that would be really useful.
Thanks,
Allan
Ok, will try to setup a test suite, perhaps as late as Monday/Tuesday next week.
I've just tried creating one: https://live.datatables.net/suzusuge/1/edit .
It seems to work okay. The only change I made to the inline editing event handler code was to strip out the
dtData.logicSourcecheck and just usechanged.Allan
I'm not that used to live fiddling for creating test cases, sorry for that, I've now currently come so far on creating a test case. It doesn't work at all yet, but perhaps someone can lead me to getting the case working:
https://live.datatables.net/suzusuge/2/edit
Sorry for spamming the thread a little, in the previous link my code got mixed with the original example. Look at this link instead:
https://live.datatables.net/suzusuge/3/
The Fiddle thing can take a little bit of getting used to, and it is only useful for the most basic of cases! Stackblitz is a good alternative sometimes.
Updated example:
I made two changes:
1) Addressed the error:
Which was showing on the console by adding
idSrc: 'identifier'to the Editor initialisation.2) Removed the individual loading of Editor, since it is already in the CDN URL (doubt this made any difference, but just something I spotted).
Allan