0
votes

I just want to ask how can I add DATA ID on the buttons EDIT/DELETE here is my javascript for rendering datatable rows I wanted to put Data ID on ROW_ID like for example delete?id=1 (CI: delete/1)

    $('#data').dataTable({
    "sScrollY": "400px",
    "bProcessing": true,
        "bServerSide": true,
        "sServerMethod": "GET",
        "sAjaxSource": "<?php echo base_url(); ?>pages/datatable",
        "iDisplayLength": 10,
        "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
        "aaSorting": [[0, 'asc']],
        "aoColumns": [ null, null, null,
            {
                "mData": null,
                "sClass": "center",
                "sDefaultContent": '<a href="edit.php?id=ROW_ID" class="btn">Edit</a> / <a href="delete.php?id=ROW_ID" class="btn_remove">Delete</a>',
            }
        ]
}).fnSetFilteringDelay(700);
1

1 Answers

0
votes

Assuming you're returning the ID value in your ajax, you can use mRender

...    
    "sClass": "center",
    "mRender": function ( data, type, full ) {
        return '<a href="edit.php?id=' + full[0] + '" class="btn">Edit</a> / <a href="delete.php?id=' + full[0] + '" class="btn_remove">Delete</a>';
}

full[0] is the data row with the ID parameter. If this is in a different column, obviously you'll to change the index accordingly