save-button shows only on change, not on new line (inline)

save-button shows only on change, not on new line (inline)

MadMax76MadMax76 Posts: 149Questions: 33Answers: 1

Hi,

I have a "save-button" defined like this:

            editor_pos.inline(table.cells(this.parentNode, '*').nodes(), {
                submitTrigger: -1,
                submitHtml: '<i class="fa fa-save" style="font-size:24px;"/>'
            });

Thsi only shows when changing a line in inline-mode. I need this button also for new lines.

I tried this:

    { extend: 'create',
                    text: 'Neu',
                    **submitHtml: '<i class="fa fa-save" style="font-size:24px;"/>',**
                    action: function () {
                        editor_pos.inlineCreate();

                        //      var row = table.row({selected: true}).data();
                        var rowlast = table.row( ':last-child' ).data();

                        var fields = editor_pos.displayed();

                        for (var i=0 ; i<fields.length ; i++) {
                            //          editor_pos.field(fields[i]).val(row[fields[i]]);
                            editor_pos.field(fields[0]).val(rowlast[fields[0]]*1 + 1);  } } },

but this does not work.

Thanks
Max

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin

    Hi Max,

    Do you mean you want to replace the standard "Save" text in the modal button with a font-awesome icon? If so, use the i18n.create.submit option and set it to be your <i> tag.

    Allan

  • MadMax76MadMax76 Posts: 149Questions: 33Answers: 1

    no, I do not want to change a text - I have this icon wfhen editing a row:

    But this does not show when creating a new line:

    Thanks
    MAx

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin

    How are you triggering the inline create action? If you have a look at this example you'll see that I use submitHyml and submitTrigger for the formOptions for the button. That might be what is missing here?

    Allan

  • MadMax76MadMax76 Posts: 149Questions: 33Answers: 1

    getting closer ;-)

    here how this is called within "buttons":

                    { extend: 'createInline',
                        text: 'NeuX',
                        editor: editor_pos,
                        formOptions: {
                            submitTrigger: -1,
                            submitHtml: '<i class="fa fa-save"/>' },
    /*  ---- START IF I take this out it works----
                    action: function () {
                            editor_pos.inlineCreate();
    
                            //      var row = table.row({selected: true}).data();
                            var rowlast = table.row( ':last-child' ).data();
    
                            var fields = editor_pos.displayed();
    
                            for (var i=0 ; i<fields.length ; i++) {
                                //          editor_pos.field(fields[i]).val(row[fields[i]]);
                                editor_pos.field(fields[0]).val(rowlast[fields[0]]*1 + 1);  } }
    ---- IF I take this out it works END ----   */
    }
    

    it works if I eliminate the function shown.

    Thanks
    Max

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    Answer ✓

    Hi Max,

    Change:

                    action: function () {
                            editor_pos.inlineCreate();
    

    to be:

            action: function( e, dt, node, config ) {
                config.editor.inlineCreate(config.position, config.formOptions);
    

    The problem is that you are replacing the default action of the createInline button, so you need to perform a similar action to what it is doing.

    Alternatively you could use:

            action: function( e, dt, node, config ) {
                $.fn.dataTable.ext.buttons.createInline.action.call(this, e, dt, node, config);
    

    to call the original createInline action method. This is probably a better option.

    Allan

  • MadMax76MadMax76 Posts: 149Questions: 33Answers: 1

    you are a genius!!!!
    thanks
    Max

Sign In or Register to comment.