Data-Table does not work with Codeigniter

0

The page does not display the data-table, just the table created in codeigniter. Following codes CONTROLLER

public function gerenciar(){
    esta_logado();
    set_tema('footerinc', load_js(array('data-table','table')), FALSE); //carrega arquivos js
    set_tema('titulo','Gerenciamento de usuários');
    set_tema('conteudo',load_modulo('usuarios','gerenciar'));
    load_template();
}

VIEW

case 'gerenciar':
    ?>
    <div class="large-12 columns">
        <table id="table" class="large-12 data-table">
            <thead>
                <tr>
                    <th>Nome</th>
                    <th>login</th>
                    <th>Email</th>
                    <th>Ativo / Adm</th>
                    <th>Ações</th>
                </tr>
            </thead>
            <tbody>
                <?php 
                $query = $this->usuarios->get_all()->result();
                foreach ($query as $linha) :
                    echo '<tr>';
                    printf('<td>%s</td>', $linha->nome);
                    printf('<td>%s</td>', $linha->login);
                    printf('<td>%s</td>', $linha->email);
                    printf('<td>%s / %s</td>', ($linha->ativo==0) ? 'Não' : 'Sim', ($linha->adm==0) ?   'Não' : 'Sim');
                    printf('<td>%s</td>', 'Ações');
                    echo '</tr>';
                endforeach;
                ?>
            </tbody>
        </table>
    </div>

MODEL

public function get_all(){
        return $this->db->get('usuarios');
    }

Follow the JS file

$(document).ready(function(){
    $(".table").DataTable({
        "sScrollY": "400px",
        "sScrollX": "100%",
        "sScrollXInner": "100%",
        "bPaginate": false,
        "aaSorting": [[0, "asc"]]
    });
});
    
asked by anonymous 03.11.2015 / 17:51

1 answer

1

The selector is wrong, change ".table" to "#table"

$(document).ready(function(){
    $("#table").DataTable({
        "sScrollY": "400px",
        "sScrollX": "100%",
        "sScrollXInner": "100%",
        "bPaginate": false,
        "aaSorting": [[0, "asc"]]
    });
});
    
03.11.2015 / 18:00