add functions to edit, new and delete buttons

add functions to edit, new and delete buttons

ifgeniaifgenia Posts: 7Questions: 1Answers: 1
edited August 2018 in Free community support

Salute! Im new here and I use symfony, jquery datatables and editor. I have an custom table and the data coming from symfony controller and database entity. I added the Editor buttons to modify every entry and create/delete one. But the buttons have no functions, if i click on new --> the popup is open, if i click on create --> no error, what I have expected. If I select one entry and click on edit --> nothing happens, no popup is coming! delete --> nothing happens..How can I add custom functions to the Editor buttons?! Help me please!

ps: maybe i can modify the actions of Editor buttons first, if I buy the full-version???

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Can you give me a link to the page you are working on so I can help debug the issue please?

    Thanks,
    Allan

  • ifgeniaifgenia Posts: 7Questions: 1Answers: 1
    edited August 2018

    Hi Allan, thanks for your answer! but it is an local project and dont running atm in the webspace...I would buy the full version, if it helps me to resolve my not really magic problems with the buttons, if not --> i have to implement the same dialogs by myself, if it is not possible to customize the functions...The add/create Buttons should call an ajax function and pass the fields-parameter to my symfony controller. Thats it! I dont need the insert in the table to same time, i will reload the complete table after adding in the database...

  • ifgeniaifgenia Posts: 7Questions: 1Answers: 1

    I found out: i can insert buttons as custom buttons and extend for exaple the new-button.. like this:

    buttons: [

        { extend: "edit", editor: editor },
        { extend: "remove", editor: editor },
    
        {   extend: "create",
            text: 'Neu',
            editor: editor,
            formButtons:
                     [
            {
              label: 'Abbrechen',
              fn: function () {
                    this.close();
            }
            },
            {
             label: 'Save',
               fn: function () {
        var el = document.getElementById('DTE_Field_field1');
        var el2 = document.getElementById('DTE_Field_field2');
        console.log(el.value);
        console.log(el2.value);
    
    
            }
        },
    ]
    

    Now I can pass the parameter from the dialog into my ajax call! Ok!
    But why is the Edit Button not working --> if I select some row from table with checkbox, and click on edit button --> nothing happens?! I expected the dialog with the selected row!

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Are there any errors shown in the browser's console?

    Allan

  • ifgeniaifgenia Posts: 7Questions: 1Answers: 1
    edited August 2018

    Unfortunatelly not! Nothing happens and no errors. If i click on the edit button, it change the color in blue and thats it - no dialog coming!

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Can you show me your full Javascript code for DataTables and Editor please?

    Allan

  • ifgeniaifgenia Posts: 7Questions: 1Answers: 1
        $(document).ready(function (){
    
            editor = new $.fn.dataTable.Editor( {
    
                table: "#step3",
                fields: [ {
                    label: "Normname:",
                    name: "field1"
                }, {
                    label: "Norm Titel:",
                    name: "field2"
                }
                ]
            } );
    
            var tableStep3 = $('#step3').DataTable({
    
                dom: "Bfrtip",
                order: [[ 3, "desc" ]],
                columns: [
                    {
                        data: null,
                        defaultContent: '',
                        className: 'select-checkbox',
                        orderable: false
                    },
    
                    { data: "field1" },
                    { data: "field2" },
                    null,
                    null
    
                ],
                select: true,
                buttons: [
    
                    { extend: "edit", editor: editor },
                    { extend: "remove", editor: editor },
    
                    {   extend: "create",
                        text: 'Neu',
                        editor: editor,
    
                        formButtons: [
                            {
                                label: 'Abbrechen',
                                fn: function () {
                                    this.close();
                                }
                            },
                            {
                                label: 'Speichern',
                                fn: function () {
                                    var el = document.getElementById('DTE_Field_field1');
                                    var el2 = document.getElementById('DTE_Field_field2');
    

    //do some ajax stuff - insert into db

                                }
                            },
                        ]
    
                    }
                ]
            });
    
        });
    
  • ifgeniaifgenia Posts: 7Questions: 1Answers: 1

    Hi Alan, the new button is working if i dont use the standard "create new entry". Instead i inserted own buttons: cancel & save...if i click on save, i can pass the parameter into ajax call... But main problem is with edit button: it doenst invoke the dialog with selected row....

  • ifgeniaifgenia Posts: 7Questions: 1Answers: 1
    Answer ✓

    I have resolved the problem....The console was of firefox was destroyed, its the reason, why i doesnt saw the error. I found the error, it was no dynamic ID in the tr of table., thats what the problem...just html error

This discussion has been closed.