Adding a print PDF function

Adding a print PDF function

mccloudmccloud Posts: 35Questions: 15Answers: 2
edited February 2017 in Editor

After using the generator to create a data-table called tasks, how do I add a "print pdf" function.? Would it be in the file /js/table.tasks.js?

(function($){ 
$(document).ready(function() { 
    var editor = new $.fn.dataTable.Editor( {
        ajax: 'php/table.tasks.php',   
        table: '#tasks', 
        fields: [
            {
                "label": "em:",
                "name": "em",
                "type": "select",
                "options": [
                    "Br",
                    "Multimedie",
                    "Pt"
                ]
            },
            {
                "label": "bruger:",
                "name": "bruger",
                "type": "select",
                "options": [
                    "M ",
                    "M "
                ]
            },
            {
                "label": "opgave:",
                "name": "opgave",
                "type": "textarea"
            },
            {
                "label": "opr:",
                "name": "opr",
                "type": "datetime",
                "format": "DD-MM-YY"
            },
            {
                "label": "deadline:",
                "name": "deadline",
                "type": "datetime",
                "format": "DD-MM-YY"
            },
            {
                "label": "Status:",
                "name": "status",
                "type": "select",
                "options": [
                    "igang",
                    " vente",
                    "f\u00e6rdig"
                ]
            }
        ]
    } );

    var table = $('#tasks').DataTable( {
        ajax: 'php/table.tasks.php',
        columns: [
            {
                "data": "emne"
            },
            {
                "data": "bruger"
            },
            {
                "data": "opg"
            },
            {
                "data": "opr"
            },
            {
                "data": "deadline"
            },
            {
                "data": "status"
            }
        ],
        select: true,
        lengthChange: false
    } ); 

    new $.fn.dataTable.Buttons( table, 
 [
        { extend: "create", editor: editor },
        { extend: "edit",   editor: editor },
        { extend: "remove", editor: editor } 

    ] ); 
    table.buttons().container()
        .appendTo( $('.col-sm-6:eq(0)', table.table().container() ) );
} );

}(jQuery));

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,920Questions: 1Answers: 10,153 Site admin
    Answer ✓

    Yes - in the buttons array where you are adding the Editor buttons. There is an example available here (although note that it has the buttons creation in the DataTable init rather than in its own).

    Allan

This discussion has been closed.