Custom button to view the form

Custom button to view the form

sbandasbanda Posts: 5Questions: 1Answers: 0

Hello,

I have created a custom button to view the form. It is working fine but when I disable all fields it affect also the edit button. So basically I want to disable all fields on the form when the custom view button is clicked. My problem is that it disables all the fields when edit button is clicked also. I want to disable only for the view button.

Here is my code for the view button.

buttons: [
{
extend: "selected",
text: 'View',
name: 'view',
action: function ( e, dt, node, config ) {
// Start in edit mode, and then change to create

                editor.edit(table.row( { selected: true } ).index(), {
                   title: 'View Branch',
                    buttons: 'Close'
                });
                editor.disable();
                e.preventDefault();
            }
       },
       { extend: 'create', name: 'new', editor: editor },
       { extend: 'edit', name: 'edit', editor: editor },
       { extend: 'remove', name: 'delete', editor: editor }

Regards

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923

    See if you can use enable() in the close event.

    Kevin

  • sbandasbanda Posts: 5Questions: 1Answers: 0

    Must I remove the editor.disable();?

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923
    Answer ✓

    Must I remove the editor.disable();?

    No.

    When the form is closed the close event will be triggered. This is what I had in mind:

    editor.on( 'close', function () {
        editor.enable();
    } );
    

    Kevin

  • sbandasbanda Posts: 5Questions: 1Answers: 0

    Thank you very much, it is working.

This discussion has been closed.