theme->baseUrl; ?>/css/datatables/dataTable...">

JQuery dataTables not working

These are the stylesheets I used

<link href="<?php echo  Yii::app()->theme->baseUrl; ?>/css/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />

      

and

<script src="<?php echo  Yii::app()->theme->baseUrl; ?>/js/plugins/datatables/dataTables.bootstrap.js" type="text/javascript"></script>
<script src="<?php echo  Yii::app()->theme->baseUrl; ?>/js/plugins/datatables/jquery.dataTables.js" type="text/javascript"></script>

      

My scripts

<script type="text/javascript">
        $(function() {
        alert("test");
            $("#example1").dataTable();
            $('#example2').dataTable({
                "bPaginate": true,
                "bLengthChange": false,
                "bFilter": false,
                "bSort": true,
                "bInfo": true,
                "bAutoWidth": false
            });
        });
    </script>

      

My tables

<table id="example1" class="table table-bordered table-striped">
</table>

      

On my page, search and pagination is not working ...

Please help me .. Try to fix this ... Thanks ..

+3


source to share


1 answer


First of all, I would recommend you search if anyone else has created some kind of extension for this plugin and is using it: http://www.yiiframework.com/extension/edatatables/ it looks great!



If you don't want to use the extension and want to use your own code, try using the browser developer tools to see if there are any errors in JavaScript, if you are not loading javascript and css, if none of them helps, try pasting here full table code so that we can see if there is any problem with the data, maybe I don't see something wrong with the code you pasted, just make sure its version is 1.9 and not 1.10, in 1.10 parameters slightly different, you can see it here: https://datatables.net/reference/option/

0


source







All Articles