DataTables logo DataTables

via Ad Packs
Display dynamic number of items in a column
  • ckfmanckfman
    Posts: 1
    I am trying to create a column that can display a dynamic number of values separated by a comma. This is a a controlled field that allows between 0 and 3 entries. For example, my JSON data looks like this (sanitized by hand, so apologies if I get a bracket wrong or something):

    {"aaData":[{"info":{"client_id": 1, "client_name":"Sample Client Name"},"support":{"SupportType1":{"44":"SampleUser1", "56":"SampleUser2"}}}]}

    What I want is to display "SampleUser1, SampleUser2".

    Here is what I have tried with no luck

    Attempt 1:
    "aoColumns": [
    { "mDataProp": "info.client_name", "sWidth": "18%"},
    {
    "fnRender": function( o, val) {
    return(val.join(", "))
    }
    },
    { "mDataProp": function() {return support.CSM.join()}}
    ]

    Attempt 2:
    "aoColumns": [
    { "mDataProp": "info.client_name", "sWidth": "18%"},
    { "mDataProp": function() {return support.CSM.join()}}
    ]

    Attempt 3:
    "aoColumnDefs": [
    {
    "fnRender": function ( o, val ) {
    return val.join
    },
    "aTargets": [ 1 ]
    }
    ],

    Any ideas (I have been able to $.map over the data, assign it to a value, and then display it in the console, but when I try to return the value the table stops rendering.)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Support

Get useful and friendly help straight from the source.