Cancel order, while moving a row

Cancel order, while moving a row

Da9LDa9L Posts: 4Questions: 2Answers: 0

Is it somehow possible to cancel a reordering process, while in the middle of it? An example being, you want to move a row, and click and drag on the handle to move it, but while moving, you wish to cancel it, by pressing the esc key, and have the row fall back to its starting position.

Answers

  • colincolin Posts: 15,091Questions: 1Answers: 2,580

    This thread should help, it's asking the same thing.

    Cheers,

    Colin

  • Da9LDa9L Posts: 4Questions: 2Answers: 0

    I didn't see a specific solution in that thread

    I have however found a solution that I'm fine with. I'm using the pre-row-reorder event and simply refreshing the whole page on the esc key press.

    table.on("pre-row-reorder", function ( e, node, index ) {                
        document.addEventListener("keydown", (event) => {
            if(event.key=="Escape") {
                location.reload();
            }                    
        }, false);
    });
    

    You could probably do something like redrawing the table etc. but this is good enough for me :-)

  • colincolin Posts: 15,091Questions: 1Answers: 2,580

    Nice, thanks for posting - I'm sure that'll be useful for others,

    Colin

Sign In or Register to comment.