Enabling and Disabling KeyTable on Editor window open and close (preClose event)
Enabling and Disabling KeyTable on Editor window open and close (preClose event)
I'm trying to use both inline and multi-row editing working on my table, and am finding everything's working great except for my attempt to get KeyTable to enable and disable when the Editor popout window appears. While I can get KeyTable to disable using the .on('open')
event, I'm unable to hook into the .on('preClose')
event to find out if the editor type that's closing is "main" or not.
// Disable Key Navigation when Editor popup window is opened
editor.on('open', function (e, type) {
if (type == "main") {
alert("main editor window opening");
courseworkMarksTable.keys.disable();
}
})
// Enable Key Navigation when Editor popup window is closed
.on('preClose', function (e, type) {
alert("closing " + type);
if (type == "main") {
alert("main editor window closing");
courseworkMarksTable.keys.enable();
}
});
I am using DataTables 1.10.10 and Editor 1.5.4.
This question has an accepted answers - jump to answer
Answers
I've fixed this for now by removing the if statement from the preClose function entirely; re-enabling KeyTable on any type of editor preClose (main or inline) gives me the desired end result.
preClose
doesn't give the editing type as a second parameter (seepreClose
reference documentation - it only gives the event parameter). Likewise weclose
which is the event I would probably suggest you use rather thanpreClose
which can be cancelled.Your suggestion of no condition for reenabling is probably the best way at the moment.
Allan
Thanks Allan. I'll change the code to use the close event instead.