Enabling and Disabling KeyTable on Editor window open and close (preClose event)

Enabling and Disabling KeyTable on Editor window open and close (preClose event)

stuartsjb-icrstuartsjb-icr Posts: 59Questions: 12Answers: 0

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

  • stuartsjb-icrstuartsjb-icr Posts: 59Questions: 12Answers: 0

    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.

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Answer ✓

    preClose doesn't give the editing type as a second parameter (see preClose reference documentation - it only gives the event parameter). Likewise we close which is the event I would probably suggest you use rather than preClose which can be cancelled.

    Your suggestion of no condition for reenabling is probably the best way at the moment.

    Allan

  • stuartsjb-icrstuartsjb-icr Posts: 59Questions: 12Answers: 0

    Thanks Allan. I'll change the code to use the close event instead.

This discussion has been closed.