Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

DataTable - merge two data fields in on column using render #6129


User avatar
0
deltavision created

Hi,

how can I render two data fields into one column - this code gives med "undefined undefined"

    var dataTable = _$customersTable.DataTable({
        paging: true,
        serverSide: true,
        processing: true,
        listAction: {
            ajaxFunction: _customerService.getCustomers,

        .....


           {
                targets: 5,
                data: "addressStreet",
                render: function (record) {
                    return record.addressStreet + " " + record.addressNumber;
                }

3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    Looking at the content using console.log(record)?

  • User Avatar
    0
    deltavision created

    Hi,

    record is just the variable/placeholder for the addressStreet data. I contains the value from there.

    So what I need is somehow to get the record/row element from the datatable.

    /Michael

  • User Avatar
    1
    deltavision created

    Hi again

    sometimes looking into the documentation helps ;-)

    https://datatables.net/reference/option/columns.render

    This works:

                {
                    targets: 6,
                    data: "addressStreet",
                    render: function (data, type, row, meta) {
                        return row.addressStreet + " " + row.addressNumber;
                    }
    

    Thank you for input. Closing this case

    /Michael