Testing DataTables Editor - not working

Testing DataTables Editor - not working

asleasle Posts: 96Questions: 28Answers: 0
edited May 2022 in Free community support

I am testing Editor but can not get the EDIT buttons to show.
Here is my take on "simple.html" fron the examples:
https://wilfavarmepumpe.no/demo/Editor-PHP-2.0.7/examples/simple/simple_wilfa.html

I also want to show the checkboxes but even if they are in the ajax data they do not trigger the checkbox.

Sorry but I get no errors in Chrome devtools so I don't know where to look for errors!

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954
    Answer ✓

    but can not get the EDIT buttons to show.

    You don't have these options in your Datatables init code:

            select: true,
            buttons: [
                { extend: "create", editor: editor },
                { extend: "edit",   editor: editor },
                { extend: "remove", editor: editor }
            ]
    

    I also want to show the checkboxes but even if they are in the ajax data they do not trigger the checkbox.

    You don't have this code from the Editor checkbox example to update the checkbox:

            rowCallback: function ( row, data ) {
                // Set the checked state of the checkbox in the table
                $('input.editor-active', row).prop( 'checked', data.active == 1 );
            }
        } );
    

    And this code to save the checkbox state to the DB via Editor:

        $('#example').on( 'change', 'input.editor-active', function () {
            editor
                .edit( $(this).closest('tr'), false )
                .set( 'active', $(this).prop( 'checked' ) ? 1 : 0 )
                .submit();
        } );
    

    Kevin

  • asleasle Posts: 96Questions: 28Answers: 0

    Thanks so much for fast and great help! I now can edit the records. But the checkbox is not checked even if the field is "1". When I click edit, the checkbox is checked but in the table it is unchecked. What did I miss in the code?

  • asleasle Posts: 96Questions: 28Answers: 0

    Sorry! Fixed it now. I had to change the field name in the function from data.active == 1 to data.aktiv == 1 since my fieldname is **aktiv **.

Sign In or Register to comment.