Button click to change value

Button click to change value

hyklhykl Posts: 48Questions: 19Answers: 5

I ask you and please you for help me for small source code for - button click to change value:

  1. example - this is working
$('a.editor_create').on('click', function (e) {
                    e.preventDefault();
                    editor.create({
                        title: 'NEW ROW',
                        buttons: 'CREATE',
                        onEsc: 'blur'
                    });
                });
  1. example:

https://editor.datatables.net/examples/api/triggerButton.html - for add cost price.

I want to source code for I click to CHANGE, then field will changed to value in string - 'YES'.

Thank you.

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    I click to CHANGE

    Click what to change?

    You can use the field().val() method to set a value.

    Allan

  • hyklhykl Posts: 48Questions: 19Answers: 5

    Please for source code, i want to manual button:
    example:

    buttons: [
                            {extend: "create", editor: editor},
                            {extend: "edit",   editor: editor},
                            {extend: "remove", editor: editor},
                            {extend: "change", editor: editor}
                        ],
    
    $('#example').on('click', 'a.editor_change', function (e) {
                        e.preventDefault();
                        editor.change( 
                              .edit( row, false );
                              .val( 'name', 'Updated name' );
                              .val( 'access', 'Read only' );
                              .submit();
                        });
    });
    
    
    <a href="" style="float: right;" class="editor_change">
    <button type="button" style="background-color: #388e3c; font-weight: bolder; border: 0;" class="btn w-icon btn-primary waves-effect waves-light">CHANGE</button>
    </a>
    
    

    Not working :(

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    That doesn't look like valid Javascript. There is no change button that can be extended unless you have defined it yourself?

    Have you read over the custom button documentation?

    Happy to write an example for you under the support options.

    Allan

This discussion has been closed.