How to get invisible cells in DataTables createdRow or rowCallBack

How to get invisible cells in DataTables createdRow or rowCallBack

mahmuttascimahmuttasci Posts: 2Questions: 1Answers: 0
edited May 2019 in Free community support

Hi brothers, I have a problem, I made a statement from the title if I need to open a little more I used DataTable Column Visible
and I want to push data in invisible column but I couldnt find invisible columns.

code:

 
 "columnDefs": [
                {"targets": [6, 7, 8, 9, 10, 11, 12, 13, 14], "visible": false,},
                {"className": "text-center", "targets": [6, 7, 10]}
            ],

"createdRow": function (row, data, index,) {
                var $cells = row.cells[8] //invisible columns ;
                debugger
                if ($.type(data.subject) === 'object') {
                    descriptionModalButton = MyButton //this is html button I not writing in pre tag ;(
                    $cell.html(descriptionModalButton);
                    $cell.append('p class="description" hidden>' + data.subject.subject + 'p')
                }
            },

var $cells = row.cells[8] // problem here rows.cells[8] returning undefined

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,144Questions: 26Answers: 4,918
    Answer ✓

    According to the createdRow docs the row parameter is the tr row element. The data parameter contains the data for the row. So you would use something like this var $cells = data[8] //invisible columns ;.

    Kevin

  • mahmuttascimahmuttasci Posts: 2Questions: 1Answers: 0

    Hi Kevin, thank you for everything.

     found a solution in a different way.
    
    "columns": [ data :"incoming_documents", "visible" :false,
        "render":
    function (cellData, cellType, rowData, meta) {
        if ($.type(cellData) === 'string') return cellData;
        var pTags = '';
        $.each(cellData, function (key, incomingDocDict) {
            pTag = mypTag
    
            pTags = pTags + pTag
        });
        incomingModalButton = '<button type="button" class="btn btn-default btn-rounded incomingModalButton" data-toggle="modal">' +
            '<span class="fa fa-file" aria-hidden="true"></span></button>' + pTags;
        return incomingModalButton
    }
    
    ]
    
This discussion has been closed.