How to return mjoin?

How to return mjoin?

nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2
edited May 2018 in DataTables

Not sure if I am asking this right. But trying my best. Using the example below, instead of returning a name field from the database, how would I return a mjoin value? For example, instead of d.name, something like [, ].name that would be rendered in a column?

function format ( d ) {
return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
'<tr>'+
'<td>Full name:</td>'+
'<td>'+d.name+'</td>'+
'</tr>'+
'</table>';
}

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @nicoledramirez@hotmail.com ,

    I'm not sure that I follow your question, but a good way to manipulate the data in a cell is to use columns.render - this can change the displayed data to be anything you want.

    Cheers,

    Colin

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I think, if I understand correctly, you want to show the array information from the Mjoin in a child row. Is that correct?

    If so, then use a for loop inside your format function to spin over the d.name array and add add whatever HTML you want for each entry (a row per name for example?).

    Allan

  • nicoledramirez@hotmail.comnicoledramirez@hotmail.com Posts: 60Questions: 14Answers: 2
    edited May 2018

    Ok, kind of changed my game plan a bit yesterday and decided I wanted this items as a row group. Not getting results returned.

    rowGroup: {
      endRender: function(rows, group) {
        return $( < tr / > )
      },
      dataSrc: function(d) {
        for (var i = 0; i < d.address_book.length; i++) {
          $(#address)
            .append(d.address_book[i].string);
        }
        return <b > Address(es): < /b><div id=address></div > ;
      }
    }
    
  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Can you give us a link to a live example, as that would help. It looks like there are missing quotes in your code. Also, unless that dataSrc function return value is matched in the data, it won't be grouping anything.

This discussion has been closed.