Keep focus on cell in error state for inline edit

Keep focus on cell in error state for inline edit

FreundFreund Posts: 6Questions: 2Answers: 0

http://live.datatables.net/raqoqihe/1/edit

Sorry if this issue has come up before, I couldn't find anything.
I am using the Keytable and Select extension and inline edit. Tab-key is used to tab through the cells.
Also using the initSubmit event to validate input.

My issue is that it's possible to move "focus" - the orange hard edit borders - away from a cell in error state. Either by keep tabbing or click on a new cell.
True the cursor stays in the error cell, but is it also possible to have the orange borders to revert back to the error cell.

I have attached a simplified example where I have added validation for first_name cannot be empty.

Thank you

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    This thread might help - it's a bit convoluted but the discussion is the same issue that you reported.

    Colin

  • FreundFreund Posts: 6Questions: 2Answers: 0

    Thanks Colin.
    I get the idea, but to me in my use case it feels like a bug in Keytable. The hard edit orange border shouldn't go on a walkabout when tabbing, but stay on the cell in error state.

    I tried using the key-focus event to refocus the error cell, see here:
    http://live.datatables.net/raqoqihe/4/edit

    It kind of works, but impose a new issue; If I - from the cell in error mode - hit Esc or correct the cell input, then the soft edit border stay on the cell and the following cell goes into edit mode, with no border!

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Answer ✓

    Use preSubmit for client-side validation: http://live.datatables.net/raqoqihe/6/edit .

    KeyTable has an event listener specifically for that event being cancelled, which will retain the focus on the current cell.

    Allan

  • FreundFreund Posts: 6Questions: 2Answers: 0

    Sorry for the late follow-up @allan.
    This works perfect now, of course there is no bug, just stupid users.
    Thanks a lot :)

This discussion has been closed.