github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/public/js/datatables/demo.js (about)

     1  +function ($) { "use strict";
     2  
     3    $(function(){
     4  
     5    // datatable
     6    $('[data-ride="datatables"]').each(function() {
     7      var oTable = $(this).dataTable( {
     8        "bProcessing": true,
     9        "sAjaxSource": "js/datatables/datatable.json",
    10        "sDom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",
    11        "sPaginationType": "full_numbers",
    12        "aoColumns": [
    13          { "mData": "engine" },
    14          { "mData": "browser" },
    15          { "mData": "platform" },
    16          { "mData": "version" },
    17          { "mData": "grade" }
    18        ]
    19      } );
    20    });
    21  
    22    $('#growthrate').length && $.ajax('js/datatables/growthrate.csv').done(function(re){
    23      var data = $.csv.toArrays(re);
    24        $('#growthrate').html( '<table cellpadding="0" cellspacing="0" border="0" class="table table-striped m-b-none" id="example"></table>' );
    25        $('#example').dataTable( {
    26            "aaData": data,    
    27            "bProcessing": true,
    28            "sDom": "<'row'<'col-sm-6'l><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",
    29            "iDisplayLength": 50,
    30            "sPaginationType": "full_numbers",
    31            "aoColumnDefs": [              
    32                { "bSearchable": false, "bVisible": false, "aTargets": [ 1 ] },
    33                { "bVisible": false, "aTargets": [ 4 ] },
    34                {
    35                    "mRender": function ( data, type, row ) {
    36                        return data +' '+ '%';
    37                    },
    38                    "aTargets": [ 5 ]
    39                },
    40                {
    41                    "mRender": function ( data, type, row ) {
    42  
    43                        return '<i class="fa '+ (row[5] > 0 ? 'fa-sort-up text-success' : 'fa-sort-down text-danger')+'"></i>';
    44                    },
    45                    'bSortable': false,
    46                    "aTargets": [ 6 ]
    47                },
    48            ],
    49            "aoColumns": [
    50                { "sTitle": "Country or Area" },
    51                { "sTitle": "Subgroup" },
    52                { "sTitle": "Year" },
    53                { "sTitle": "source", "sClass": "center" },
    54                { "sTitle": "Unit", "sClass": "center" },
    55                { "sTitle": "Value", "sClass": "center" },
    56                { "sTitle": "", "sClass": "center" }
    57            ]
    58        } );  
    59    }); 
    60  
    61  
    62  
    63  
    64    });
    65  }(window.jQuery);