demo.js 2.2 KB

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