How to show several values in the same cell of a datatable

0

I'm having trouble showing several values of different fields in the database in the datatable. The code I have from the table is:

var listar = function () {
var table = $('#customers-table-view').DataTable({
    destroy: true,
    ajax: {
        method: 'POST',
        url: 'listar'
    },
    columns: [
        {'data': 'customer_code'},
        {'data': 'tax_number'},
        {'data': 'company_name'},
        {'data': 'city'},
        {'data': 'state'},
        {'data': 'service1'},
        {"defaultContent": $botones}
    ],

In the database I have service1, service2, service3 ... on or off. What I would like is to get those values in the same column. That is to say that in the cell something like that remained; On, Off, Off ... Then I will render the on and the off Thank you very much.

    
asked by Jose 10.03.2018 в 15:50
source

1 answer

0

Finally I have found the solution to the problem. Or rather they have helped me in SO in English. I share it here so that if someone has the same problem I can find the solution.

$('#customers-table-view').DataTable({
columns: [
...
{ 
  data: 'servicios',
  render: function (data, type, row, meta) {
    return row.service1 + ', ' + row.service2 + ', ' + row.service3
  }
},
...

] });

Greetings.

    
answered by 11.03.2018 / 21:39
source