multiple data in single cell

multiple data in single cell

pankaj3145pankaj3145 Posts: 10Questions: 3Answers: 0

i need to insert multiple data one below other in single cell of column how to achieve it?

Answers

  • pankaj3145pankaj3145 Posts: 10Questions: 3Answers: 0

    https://stackoverflow.com/questions/32088676/how-to-add-rowspan-in-jquery-datatables basically i need to achieve this but here data is hard coded my data comes from MySQL database dynamically

  • rf1234rf1234 Posts: 2,956Questions: 87Answers: 416

    You could do it like this simply using html to go to the next line within the cell:

    columns: [            
        {   data: "creditor.name",
            render: function ( data, type, row ) {
                return row.creditor.name + '<br>(' + row.creditor.city + ')';
            }
        },
    

    This will produce a column content like:
    SomeName
    (SomeCity)

  • pankaj3145pankaj3145 Posts: 10Questions: 3Answers: 0

    thanks can you give some live example

  • rf1234rf1234 Posts: 2,956Questions: 87Answers: 416

    No.

    Just a screenshot

    The name covers 2 lines here because column width is small. But you can change that easily.

    I also get my data from MySQL via ajax. So this will work for you as well.

    Here is the more complete table definition:

    var inboxRfaOfferCredTable = $('#tblInboxRfaOfferCred').DataTable( {
        dom: "Bfrtip",
        ajax: {
            url: 'actions.php?action=tblInboxRfaOfferCred'
        },
        columns: [            
            {   data: "creditor.name",
                render: function ( data, type, row ) {
                    return row.creditor.name + '<br>(' + row.creditor.city + ')';
                }
            },
    
  • pankaj3145pankaj3145 Posts: 10Questions: 3Answers: 0
    edited November 2018

    i dont use ajax this is how i assign value to row

    if(user.getDataValue('transaction_tbls').length > 0)
    for tr in user.getDataValue('transaction_tbls')
    th= (tr['dataValues'])['designation']
    i have multiple designations but only one designation assigns to row other shifts to right side

  • pankaj3145pankaj3145 Posts: 10Questions: 3Answers: 0

  • rf1234rf1234 Posts: 2,956Questions: 87Answers: 416

    not sure what that means.
    Please take a look at the docs: https://datatables.net/reference/option/columns.render

This discussion has been closed.