Orthogonal Data Generated Column Content

Orthogonal Data Generated Column Content

imseandavisimseandavis Posts: 2Questions: 1Answers: 0

So this is the example used for generating column content.

$(document).ready(function() {
var table = $('#example').DataTable( {
"ajax": "data/arrays.txt",
"columnDefs": [ {
"targets": -1,
"data": null,
"defaultContent": "<button>Click!</button>"
} ]
} );

$('#example tbody').on( 'click', 'button', function () {
    var data = table.row( $(this).parents('tr') ).data();
    alert( data[0] +"'s salary is: "+ data[ 5 ] );
} );

} );

But when I use orthonogonal data in the example below I always get undefined back. I want to generate a url based on the server name in the VM_Name field

    $(document).ready(function() {
        var complianceTable = $('#compliance').dataTable( {
            "ajax": {
                "url": "data/Compliance_Report.json",
                "dataSrc": ""
            },
            "paging": true,
            "stateSave": true,
            "dom": 'T<"clear">lfrtip',
            "tableTools": {
                "sSwfPath": "/swf/copy_csv_xls_pdf.swf"
            },
            "columns": [
                { "data": "vCenter_Label" },
                { "data": "vCenter" },
                { "data": "VM_Name" },
                { "data": "VM_OS" },
                { "data": "VM_CPU_Cores" },
                { "data": "VM_RAM" },
                { "data": "VM_Power_State" },
                { "data": "VM_Tools_Status" },
                { "data": "VM_Tools_Version_Status" },
                { "data": "VM_Tools_Running_Status" },
                { "targets": -1,
                  "data": null,
                  "defaultContent": "<button id='hi'>Get Server Details</button>"
                }
            ]

                             $('#example tbody').on( 'click', 'button', function () {
                                  var data = complianceTable.row( $(this).parents('tr') ).data();
                                  alert( "http://url.com/" + data[2] );
                             } );
        });

I would expect every button to generate a popup with the appropriate url: http://url.com/servernamegoeshere

Any help would be greatly appreciated. This seems to be an issue only when I use orthogonal data.

Answers

  • imseandavisimseandavis Posts: 2Questions: 1Answers: 0

    I've narrowed down the the problem to this line

    var data = complianceTable.row( $(this).parents('tr') ).data();

This discussion has been closed.