Commit 25fa8361 authored by cygnet's avatar cygnet

changes for datatable

parent 0241a481
......@@ -315,7 +315,7 @@ var Backend = {}; // common variable used in all the files of the backend
init: function (dataTable) {
this.setSelectors();
this.addHandlers();
this.addHandlers(dataTable);
},
setSelectors:function(){
......@@ -339,7 +339,7 @@ var Backend = {}; // common variable used in all the files of the backend
Backend.DataTableSearch.setSelectors();
callback(this.selector.searchInput);
},
addHandlers:function(){
addHandlers:function(dataTable){
// get the datatable search input and on its key press check if we hit enter then search with datatable
this.cloneElement(this.selector.searchInput,function(element){ //cloning done to remove any binding of the events
element.onkeypress = function(event){
......
......@@ -68,6 +68,49 @@
{{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }}
<script>
(function () {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var dataTable = $('#users-table').dataTable({
processing: true,
serverSide: true,
ajax: {
url: '{{ route("admin.access.user.get") }}',
type: 'post',
data: {status: 0, trashed: false}
},
columns: [
{data: 'first_name', name: '{{config('access.users_table')}}.first_name'},
{data: 'last_name', name: '{{config('access.users_table')}}.last_name'},
{data: 'email', name: '{{config('access.users_table')}}.email'},
{data: 'confirmed', name: '{{config('access.users_table')}}.confirmed'},
{data: 'roles', name: '{{config('access.roles_table')}}.name', sortable: false},
{data: 'created_at', name: '{{config('access.users_table')}}.created_at'},
{data: 'updated_at', name: '{{config('access.users_table')}}.updated_at'},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[0, "asc"]],
searchDelay: 500,
dom: 'lBfrtip',
buttons: {
buttons: [
{ extend: 'copy', className: 'copyButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'csv', className: 'csvButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'excel', className: 'excelButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'pdf', className: 'pdfButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }},
{ extend: 'print', className: 'printButton', exportOptions: {columns: [ 0, 1, 2, 3, 4, 5, 6 ] }}
]
}
});
Backend.DataTableSearch.init(dataTable);
})();
/*
$(function() {
var dataTable = $('#users-table').dataTable({
processing: true,
......@@ -102,6 +145,6 @@
});
Backend.DataTableSearch.init(dataTable);
});
});*/
</script>
@endsection
......@@ -81,7 +81,14 @@
{{ Html::script(mix('js/dataTable.js')) }}
<script>
$(function() {
(function() {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var dataTable = $('#users-table').dataTable({
processing: true,
serverSide: true,
......@@ -116,6 +123,6 @@
});
Backend.DataTableSearch.init(dataTable);
});
})();
</script>
@endsection
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment