DataTables - 外部数组

Happy Evening All,

I am trying to add formatting to the data that was collected in MySql and display with its corresponding array value.

MySql
name, age, gender (1=M, 0=F)
Max, 18, 1


Current DataTable Display
Max, 18, 1


DataTable (desired version)
Max, 18, M


How to add array to datatable serverside php. Also tried using Formatter - unable to get the desired display. Any help would be greatful.

something tried at my end does't work.

array( 'db' => 'gender', $arrayName('dt') => 8 ),

Thanks,

you can define each column :

$('#table').DataTable({    
"columns": [
{
    "title": "gender.", 
    "data": "gender", 
    "render": function (data, type, row) {
                 return data ? "M" : "F";
                 }
}
]
});

Complete Working solution :)

<script type="text/javascript">
$(document).ready(function() {
var genderValue = [
"Female", //0
"Male", // 1 
];
$('#example').DataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "scripts/server_processing.php",
        "columns": [
                { data : gender, 
                render: function (data, type, row) {
                return genderValue[data]
                }},
                    ]
        } );
} );
</script>