Datatables jquery showing me hidden fields

1

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">
        <thead>
            <tr>
                <th hidden>nrologins</th>
                <th hidden>Id</th>
                <th>Nombre</th>
                <th>Apellido</th>
            </tr>
        </thead>

     <tbody>
            <?php
                if ($arrDatos) {
                    foreach ($arrDatos as $row) { ?>
                <tr>
                    <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>
                </tr>
            <?php }} ?>
        </tbody>
      </table>

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
source

1 answer

2

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
source