Bekir Bozkurt
Bekir Bozkurt

Reputation: 94

How to do merge datatable fields?

database table fields : id,first_name,last_name,email

datatable : full_name,email (without id) ?

 <script type="text/javascript">
        $(document).ready(function () {


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

                "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],

                "ajax": "{{URL::to('ajaxUzmanListesi/')}}",
                "language": {
                    "url": '/lib/datatables/language/Turkish.json'
                },
                "columns": [
                    {
                        "mData": null ,
                        "mRender" : function ( data, type, full ) {
                            return full['first_name']+''+full['last_name'];}
                    }

                ]

});

});

Upvotes: 2

Views: 1210

Answers (1)

annoyingmouse
annoyingmouse

Reputation: 5699

Try this:

"columns": [{
        "data": null,
        "title": "Name",
        "render": function(data, type, full) {
            return full['first_name'] + ' ' + full['last_name'];
        }
    },
    {
        "data": "email",
        "title": "Email"
    }
]

Working JSFiddle here. Hope that helps.

Upvotes: 4

Related Questions