inline KeyTable and validation

inline KeyTable and validation

capeckcapeck Posts: 54Questions: 13Answers: 1

I am looking for a solution to have validation fire with inline editing and keytables for tabbing between columns. The validation fires if I use the Enter key, but not the tab key. My key setup is

  keys: {
                    columns: ':not(.readonly)',
                    keys: [ 9 ],
                    editor: vm.editor,
                    editOnFocus: true
                }    ,  

and a test validation on the server script

        Field::inst( 'historical_wx.am_availablesnow_nf' )

            ->validator(Validate::minMaxNum(0,3))
                ,

Thanks for any help.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    That's probably because the value isn't being saved when you tab out. You would to "submit on blur", as shown in this example, then the value will be sent to the server,

    Colin

  • capeckcapeck Posts: 54Questions: 13Answers: 1

    I don't get the on click event firing because I am using keyTable and the inline editing is initiated by the tab key. I can see the back end (server) firing on the tab key as well - it is submitting with the tab but not validating.

  • capeckcapeck Posts: 54Questions: 13Answers: 1

    I found this post:
    https://datatables.net/forums/discussion/59605

    and added the formOption to my configuration, so it now validates on tab but it just clears out the field if invalid and moves on. I would like it to act the same way as hitting the enter key and show the error message before moving on to the next field.
    Thanks.

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    It should work like that out of the box. If you load this example - the first column has a required validator on the server-side. So edit it to make it an empty input and then press tab - the focus will move on, but then bounce back when the validation error occurs.

    If that isn't working for you locally, can you link to a page showing the issue please?

    Thanks,
    Allan

  • capeckcapeck Posts: 54Questions: 13Answers: 1

    Compared that exmple to mine and when I took out

    keys: [9]
    

    from the keys options for the table it worked.
    So the table setup now looks like:

    keys: {
    columns: ':not('readonly')',
    editor: vm.editor
    }
    

    Does that make sense?

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    I've just updated that example locally to be:

            keys: {
                keys: [9],
                columns: ':not(:first-child)',
                editor:  editor
            },
    

    So now, I double click to edit a cell, make it blank and hit tab. It performs the same way as the example on the site other than that - the focus moves across and then bounces back with the error message:

    Can you give me a link to your page showing the issue perhaps?

    Allan

Sign In or Register to comment.