Cant get data from a cell in a hidden column

Cant get data from a cell in a hidden column

dezeazdezeaz Posts: 7Questions: 5Answers: 0

Hi, my table data source is loaded using an ajax request. The last column is not loaded via ajax, and i specify if the value is to be true or false. This last column is also hidden.

If i try and get the coumn data via css it doesnt work when hidden, but does when its visable.

if i try and output the row to the console using the code below i still cant see the last columns values, but all others are present?

var currentRow = $(this).closest("tr");
var columnvalue = table.row(currentRow).data();
 console.log(columnvalue);


var table = $('#table_code').DataTable({
    "ajax": {
        "url": "/api/v1/code/" + module,
        "dataSrc": "",
        'beforeSend': function (request) {
            request.setRequestHeader("Authorization", 'Bearer ' + localStorage.getItem('accessGSMToken'));
        },
        "statusCode": {
            401: function (xhr, error, thrown) {
                window.location.href = "index.html"
                return false
            }
        }
    },
    "language": {
        "emptyTable": "No codes found, please add a key.",
        "search": "_INPUT_",
        "searchPlaceholder": " Search..."
    },
    "lengthChange": true,
    "pageLength": 10,
    "lengthMenu": [[5, 10, 25, 50, 100, -1], [5, 10, 25, 50, 100, "All"]],
    "order": [[1, "asc"]],
    "createdRow": function (row, data, dataIndex) {
        if (tasks !== null && cloudProgramming) {
            if (tasks[site].module[module].Codes === true) {
                $(row).css('background-color', "#a3d3c2");
            }
            if ((tasks[site].module[module].Code).includes(data.location)) {
                $(row).css('background-color', "#a3d3c2");
            }
            if ((tasks[site].module[module].CodeRemove).includes(data.location)) {
                $(row).css('background-color', "#f7a0b1");
            }
        }
    },
    "rowId": 'id',
    "dom": "<'row'<'col-sm-12 col-md-6 AddBtn'><'col-sm-12 col-md-2'><'col-sm-12 col-md-2'l><'col-sm-12 col-md-2'f>>" +
        "<'row'<'col-sm-12'tr>>" +
        "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
    "paging": true,
    "autoWidth": true,
    "order": [[0, "asc"]],
    "columnDefs": [
        { targets: hideColArr, visible: false },
        { targets: showColArr, visible: true }
    ],
    "columns": [
        { data: 'location' },
        { data: 'code' },
        { data: 'relay1' },
        { data: 'relay2' },
        { data: 'relay3' },
        { data: 'accessLevel' },
        { data: 'name' },
        {
            "className": '',
            "orderable": false,
            "data": null,
            "defaultContent": '<a href="" id="editSiteBtn"><i class="fa fa-pen mr-5" aria-hidden="true"></i></a><a href="" id="deleteSiteBtn"><i class="fa fa-trash" aria-hidden="true"></i></a>',
            "render": function (data, type, row) {
                if (obj[module].cloudPrograming) {
                    return '<a href="" id="uploadBtn"><i class="fa fa-upload mr-5" aria-hidden="true"></i><a href="" id="editSiteBtn"><i class="fa fa-pen mr-5" aria-hidden="true"></i><a href="" id="deleteSiteBtn"><i class="fa fa-trash mr-5" aria-hidden="true"></i></a>';
                }

                return '<a href="" id="editSiteBtn"><i class="fa fa-pen mr-5" aria-hidden="true"></i><a href="" id="deleteSiteBtn"><i class="fa fa-trash" aria-hidden="true"></i></a>';
            }
        },
        {
            "defaultContent": false,
            "data": null,
            "render": function (data, type, row, meta) {
                if (tasks !== null && cloudProgramming) {
                    if ((tasks[site].module[module].Code).includes(row.location) || (tasks[site].module[module].CodeRemove).includes(row.location)) {
                        return true;
                    }
                }
            }
        }
    ]
});

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.