Created
June 29, 2015 23:34
-
-
Save matheuslao/88444ffed8713263d437 to your computer and use it in GitHub Desktop.
DataTable Custom with MomentJS and DataTools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = function() { | |
return { | |
init: function() { | |
// Initialize Bootstrap Datatables Integration | |
App.datatables(); | |
//Moment.js + datetime-moment.js to date's sorting in datatable | |
$.fn.dataTable.moment( 'DD/MM/YYYY' ); | |
// Initialize Datatables | |
var table = $('#datatable-finances-invoices').dataTable({ | |
//TableTools | |
//"sDom": 'T<"clear">lfrtip', // original TableTools sDOM | |
"sDom": '<"row"<"col-sm-4 col-xs-6"l><"col-sm-4 col-xs-6"T><"col-sm-4 col-xs-12"f>>rt<"row"<"col-sm-5 hidden-xs"i><"col-sm-7 col-xs-12 clearfix"p>>', | |
"oTableTools": { | |
"aButtons": [ | |
{ | |
"sExtends": "pdf", | |
"sButtonText": "Salvar PDF", | |
"sPdfOrientation": "landscape", | |
"sFileName": "iDojo_financeiro.pdf", | |
"mColumns": [ 0, 2, 3, 4, 5, 6, 7, 8 ], | |
"oSelectorOpts": { filter: 'applied', order: 'current' } | |
} | |
,{ | |
"sExtends": "xls", | |
"sButtonText": "Salvar Excel", | |
"sFileName": "iDojo_financeiro.xls", | |
"mColumns": [0, 2, 3, 4, 5, 6, 7, 8 ], | |
"oSelectorOpts": { filter: 'applied', order: 'current' } | |
} | |
/* | |
,{ | |
"sExtends": "copy", | |
"sButtonText": "Copiar", | |
"mColumns": [0, 2, 3, 4, 5, 6, 7, 8 ], | |
"oSelectorOpts": { filter: 'applied', order: 'current' } | |
}, | |
{ | |
"sExtends": "print", | |
"sButtonText": "Imprimir", | |
"mColumns": [0, 2, 3, 4, 5, 6, 7, 8 ], | |
"oSelectorOpts": { filter: 'applied', order: 'current' }, | |
"bShowAll": false | |
} | |
*/ | |
] | |
},//END: TableTools | |
"order": [[4,"desc"]], | |
"iDisplayLength": 10, | |
"aLengthMenu": [[10, 30, 50, -1], [10, 30, 50, "Todos"]] | |
}); | |
// Add placeholder attribute to the search input | |
$('.dataTables_filter input').attr('placeholder', 'Pesquise aqui'); | |
} | |
}; | |
}(); | |
var finances = function(){ | |
return{ | |
init: function(){ | |
foo.init(); | |
} | |
}; | |
}(); | |
$(document).on('page:load', finances.init()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment