Datatables jquery showing me hidden fields


I have a table on a page where I use the datatables.jquery plugin, which for me is very practical and functional.
It turns out that in the table I use two hidden fields, the id and the nrologins (the latter I use to sort the data that comes with the sql query)

<table id="tabla" class="ui celled stackable table">
                <th hidden>nrologins</th>
                <th hidden>Id</th>

                if ($arrDatos) {
                    foreach ($arrDatos as $row) { ?>
                    <td hidden> <?php echo $row['nrologins']; ?> </td>
                    <td hidden> <?php echo $row['id']; ?> </td>
                    <td> <?php echo $row['nombre']; ?> </td>
                    <td> <?php echo $row['apellido']; ?> </td>
            <?php }} ?>

Now, full screen, it works fine but when I reduce the screen (or for example I see it from the mobile) the "hidden" fields are shown !!! ... How can I do to prevent that from happening?

asked by MNibor 05.10.2017 в 14:51

1 answer


Try to hide the fields in your JS code, add the following in the configuration of your datatable:

$('#example').DataTable( {
    "columnDefs": [
            "targets": [ 0 ],
            "visible": false,
            "searchable": false
            "targets": [ 1 ],
            "visible": false
} ); 

Targets specify the position of the column you wish to hide.

answered by 05.10.2017 / 15:06