Add Cancel button to all windows of editor

Add Cancel button to all windows of editor

sergedasergeda Posts: 42Questions: 16Answers: 0
edited December 2014 in Editor

How can I do it? I've managed to make it for edit window like this:

       container.editor
            .title( 'Edit record' )
            .buttons([
            { "label": "Update", "fn": function () { container.editor.submit() } },
            { "label": "Cancel", "fn": function () { container.editor.close() } }
                ]
        )
            .edit( $(this).parents('tr') );

but can't make it for create window.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,840Questions: 1Answers: 10,134 Site admin

    You should be able to do the same using create():

    container.editor
         .title( 'Create record' )
         .buttons([
         { "label": "Update", "fn": function () { container.editor.submit() } },
         { "label": "Cancel", "fn": function () { container.editor.close() } }
             ]
     )
         .create();
    

    This is assuming of course that you are not using the TableTools buttons (are you?).

    Allan

  • sergedasergeda Posts: 42Questions: 16Answers: 0

    Thank you Allan. Actually for creating record I use TableTools button. How can I bind to Create button of tableTools?

  • allanallan Posts: 61,840Questions: 1Answers: 10,134 Site admin

    The Editor form buttons, for the TableTools buttons, are defined by $.fn.dataTable.TableTools.BUTTONS.editor_create (and editor_edit / editor_remove).

    So you would assign your button array to that variable.

    Regards,
    Allan

  • sergedasergeda Posts: 42Questions: 16Answers: 0

    Ok. I've tried
    $.fn.dataTable.TableTools.BUTTONS.editor_create=[ { "label": "Save", "fn": function () { container.editor.submit() } }, { "label": "Cancel", "fn": function () { container.editor.close() } } ];
    but have got the error 'TypeError: a.sAction is undefined'

  • allanallan Posts: 61,840Questions: 1Answers: 10,134 Site admin
    Answer ✓

    Sorry! My mistake - I give you the reference to the full TableTools button configuration - not the Editor buttons in it. It should be: $.fn.dataTable.TableTools.BUTTONS.editor_create.formButtons:

     $.fn.dataTable.TableTools.BUTTONS.editor_create.formButtons = [
            { "label": "Save", "fn": function () { container.editor.submit() } },
            { "label": "Cancel", "fn": function () { container.editor.close() } }
    ];
    

    Allan

  • sergedasergeda Posts: 42Questions: 16Answers: 0

    Thank you Allan. Now everything working fine

This discussion has been closed.