Show validation error message in cell, under value text, using inline editor

Show validation error message in cell, under value text, using inline editor

EdpAlmaEdpAlma Posts: 3Questions: 1Answers: 0
edited November 2021 in Editor

Hi,
I had a datatable (in Bootstrap 4 environment) with inline editor and everything works fine.

Now, I had to configure my datatable to execute validation in my inline editor, showing error message in the datatable, under the value of the cell.

I put this test code in presubmit event

        editor.on( 'preSubmit', function ( e, o, action ) {
            
            if (action == 'edit') { 
                var iniDateField = this.field( iniDate);
                iniDateField.error( 'Dummy error' );
                return false;
            }
        } );

but I dont see my custom message 'Dummy error' under the value of the cell,

How can I do this? How can I configure my datatable?

Thanks,

Davide

Answers

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    I see it here - http://live.datatables.net/xujohoca/1/edit - it appears when you inline edit the start date field. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.

    Cheers,

    Colin

  • EdpAlmaEdpAlma Posts: 3Questions: 1Answers: 0

    Thank you Colin,
    you example work for my, but only if you confirm the date pressing enter key: when you click on another cell the error message disappear.

    Furthermore, in my example I also have the datepicker in the date cell and I see the error only if I press enter key after the selected date (by datepicker) is showed in the cell.

    How to can I always show the error?

    Thanks,

    Davide

  • allanallan Posts: 61,446Questions: 1Answers: 10,055 Site admin

    Hi Davide,

    Are you doing this validation server-side as well? If so, remove what you have there and the error message should show up as expected inside the date picker (it has a listener on the Ajax complete to look for this sort of thing). If you aren't using server-side validation, you'll need to add that anyway since client-side validation is trivial to bypass.

    Allan

  • EdpAlmaEdpAlma Posts: 3Questions: 1Answers: 0

    Hi,
    i resolve the problem:
    in the table creation I add this key configuration

    "keys": {    
        columns: ':not(:first-child):not(:nth-child(2))',            
        keys: [ "\t".charCodeAt(0)],
       editor: editor,
       editOnFocus: true
    },
    

    and so this command stop to work correctly

    $('#gridElenco').on( 'click', 'tbody td', function (e) {
        editor.inline( this, {
            onBlur: 'submit'
        } );
    } );
    
    

    I can not use key extension, but anybody know why is there this incompatibily?

    Thanks,

    Davide

  • allanallan Posts: 61,446Questions: 1Answers: 10,055 Site admin

    Hi Davide,

    I'm a little confused - sorry. Why do you have a keys property if you can't use KeyTable?

    Allan

Sign In or Register to comment.