Unable to get value from selected row

Unable to get value from selected row

aarontharkeraarontharker Posts: 41Questions: 11Answers: 0
var loc = $('#locations').DataTable( {
        dom: "Bfrtip",
        "pageLength":5,
        ajax: {
            url: "./controllers/locations.php",
            type: "POST",
            data: {
                "id": frmID}
            },
        columns: [
            { data: "Locations.id",
              visible: false },
            { data: "Customers.Name" },
            { data: "Services.Name" },
            { data: "Locations.Address1"},
            { data: "Locations.Address2"},
            { data: "Locations.Contact"},
            { data: "Locations.Suburb"},
            { data: "Locations.City"},
            { data: "Locations.State"},
            { data: "Locations.Country"},
            { data: "Users",
              render: function ( data, type, row ) {
                return data.firstname +' '+ data.lastname;
              }
            }
        ],
        select: true,
        buttons: [
            { extend: "create", editor: editor },
            { extend: "edit",   editor: editor },
            { extend: "remove", editor: editor }
        ]
    } );

    loc.on( 'select', function ( e, dt, type, indexes ) {
        if ( type === 'row' ) {
            var locRow = loc.rows(indexes).data().pluck( 'Locations.id' );
            $('#subform').show();
            console.log(locRow);
        }
    } );

Can anyone see why this is not returning the Locations.id value from the table?

When I check the console log it is saying undefined.

I have tried using both 'Locations.id' and simply 'id' but neither way returns a value. Also tried making the column visible to see if that made a difference but it did not.

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.