How to add custom button in the form of editor?

How to add custom button in the form of editor?

IHSLIHSL Posts: 13Questions: 8Answers: 0

I would like to place a custom button along with Create and edit buttons on teh form popup in the editor

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 3,021Questions: 88Answers: 421
    edited July 2022 Answer ✓

    Here is a custom button that is for an Editor that has three custom buttons inside

    //custom button to download to start the ctr accouting interface editor
    $.fn.dataTable.ext.buttons.downloadCtrAcctInterface = {
        name: "downloadCtrAcctInterfaceButton",
        text: downloadCtrAcctInterfaceLabel,
        action: function ( e, dt, button, config ) {
            downloadCtrAcctInterfaceEditor
                .title(lang === 'de' ? 'FiBu-Schnittstelle anfordern' : 'Request accounting interface')
                .buttons( [
                    {
                        label: lang === 'de' ? 'Schließen' : 'Close',
                        className: 'closeButton',
                        action: function () {
                            var that = this;
                            setTimeout(function() {
                                that.close();
                            }, 100);
                        }
                    },
                    {
                        label: lang === 'de' ? 'Test-Dateien herunterladen' : 'Download test files',
                        className: 'testDataButton',
                        action: function () {
                            var that = this;
                            setTimeout(function() {
                                var prev = that;
                                that.submit( function () {
                                    prev.create();
                                } );
                            }, 300);
    
                        }
                    },
                    {
                        label: lang === 'de' ? 'Schnittstelle herunterladen' : 'Download interface',
                        className: 'btn-showall-color interfaceDataButton',
                        fn: function () {
                            var that = this;
                            setTimeout(function() {
                                var prev = that;
                                that.submit( function () {
                                    prev.create();
                                } );
                            }, 300);
                        }
                    }                
                ] )
                .create();
        }
    };
    

    To also have the "create" button in there you would need to add this to the buttons array aboove:

    {
           label: $.fn.dataTable.Editor.defaults.i18n.create.submit,
            fn: function () {
                   this.submit();
            }
     }
    

  • IHSLIHSL Posts: 13Questions: 8Answers: 0

    Thank you so much @rf1234

Sign In or Register to comment.