Datatables Editor not orking on edit and delete

Datatables Editor not orking on edit and delete

ingilaingila Posts: 12Questions: 5Answers: 0

Hi. My editor (trial version) is not working on edit and delete buttons. I am using Select extension for row selection and thinking about buying Editor if it works well. The interface I want is

Here's my code:

<script src="../vendor/datatables-buttons/js/dataTables.buttons.min.js"></script>
<!--Datatables Select-->
<script src="../vendor/datatables-select/js/dataTables.select.min.js"></script>

<!--Datatables  Editor-->
    <script src="../vendor/datatables-editor/Editor/js/dataTables.editor.min.js"></script>

    <script>        

function format ( d ) {
return '

'+ ''+ '' + '' + '' + '
File Name File Reference Document ID Isuance DateSeller Name Buyer Name Currency Amount Maturity Date
'+d.id+' ' + d.name + '' + d.position + '' + d.salary + ''+ d.start_date + '' + d.office + ''+d.extn+'' + 'Some example Data' + '' + 'Pictures etc..' + '
' + '

';
}

var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function() {

  editor = new $.fn.dataTable.Editor({
    "ajax": "../ajax/data/objects.txt",
    "table": "#example",
    "fields": [ 
        {
            "label": "ID:",
            "name": "id"
        },          
        {
            "label": "First name:",
            "name": "name"
        }, {
            "label": "Position:",
            "name": "position"
        }, {
            "label": "Salary:",
            "name": "salary"
        },          
        {
            "label": "Start date:",
            "name": "start_date",
            "type": "datetime"
        },          
        {
            "label": "Office:",
            "name": "office"
        }, 
        {
            "label": "Extension:",
            "name": "extn"
        }
    ]
} );

// Edit record
$('#example').on('click', 'a.editor_edit', function (e) {
    e.preventDefault();                 
    editor.edit( $(this).closest('tr'), {
        title: 'Edit record',
        buttons: 'Update'
    } );

} );

// Delete a record
$('#example').on('click', 'a.editor_remove', function (e) {
    e.preventDefault(); 
    editor.remove( $(this).closest('tr'), {
        title: 'Delete record',
        message: 'Are you sure you wish to remove this record?',
        buttons: 'Delete'
    } );
} )

var table = $('#example').DataTable( {

 dom: "Blfrtip",    
"ajax": "../ajax/data/objects.txt",     

"columnDefs": [ {
        orderable: false,
        className: 'select-checkbox',
        targets:   0
    } ],
"columns": [
        {
            data: null,
            defaultContent: '',
            className: 'select-checkbox',
            orderable: false
        },

        { "data": "id"},
        { "data": "name" },
        { "data": "position" },
        { "data": "salary" },
        { "data": "start_date" },
        { "data": "office" },
        { "data": "extn" },
        {
            data: null,
            className: "center",
            defaultContent: '<a href="" class="editor_edit">Edit</a> / <a href="" class="editor_remove">Delete</a>'
        }
    ],

    //select: {'style': 'multi'},     
    select:true,     
    buttons: [      
    {
      text: 'Select All',
            key: '1',
            action: function ( e, dt, node, config ) {                  
                table.rows().select();
            }

    },

    {
      text: 'Deselect All',
            key: '1',
            action: function ( e, dt, node, config ) {
                table.rows().deselect();
            }       
    }


    ],

"order": [[0, 'asc']]
});

$('#example tbody').on('click', 'td', function () { /*

    var tr = $(this).closest('tr');
    var row = table.row( tr );

    if ( row.child.isShown() ) {
         $('div.slider', row.child()).slideUp( function () {
        row.child.hide();
        tr.removeClass('shown');
         });
    }
    else {
        row.child( format(row.data()) ).show();
        tr.addClass('shown');
         $('div.slider', row.child()).slideDown();
    }


*/});
} );    

Answers

This discussion has been closed.