I have a Datatable plugin working with ajax to load the data. I want get a result in a column based on 2 conditionals. The below code is working good but with just one conditional. I'mnot sue how to add status_token to the equation. I want to add status_token variable the same as status is working.
I've tried status, status_token and { data: {'status': status, 'status_token': status_token}, render: function(status){ but it's not working.
$('#tableEvent').DataTable({
processing: true,
serverSide: true,
ajax: "{!! route('datatables.data') !!}",
columns: [
{ data: 'status_token', name: 'status_token' },
{ data: 'status', //<-- how can I add another variable status_token?
render: function(status){ //<-- same here status_token
if(status == 'hello'){
return 'aa';
}else{
if(status_token == 'bye'){
return 'bb';
}else{
return 'cc';
}
}
}
}
As per Rohit.007 suggestion I tried this code
{ data: {'status': 'status', 'status_token': 'status_token'},
render: function(status, status_token){
But for some reason it's still not working, checking out the variable status_token I get "display" no idea what's that and why it's different from the first column which is returning the correct information.
New whole code:
$('#tableEvent').DataTable({
processing: true,
serverSide: true,
ajax: "{!! route('datatables.data') !!}",
columns: [
{ data: 'status_token', name: 'status_token' },
{ data: {'status': 'status', 'status_token': 'status_token'},
render: function(status, status_token){
if(status == 'hello'){
return 'aa';
}else{
if(status_token == 'bye'){
return 'bb';
}else{
return 'cc';
}
}
}
}
],
responsive: true
});