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 ...@@ -315,7 +315,7 @@ var Backend = {}; // common variable used in all the files of the backend
init: function (dataTable) { init: function (dataTable) {
this.setSelectors(); this.setSelectors();
this.addHandlers(); this.addHandlers(dataTable);
}, },
setSelectors:function(){ setSelectors:function(){
...@@ -339,7 +339,7 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -339,7 +339,7 @@ var Backend = {}; // common variable used in all the files of the backend
Backend.DataTableSearch.setSelectors(); Backend.DataTableSearch.setSelectors();
callback(this.selector.searchInput); 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 // 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 this.cloneElement(this.selector.searchInput,function(element){ //cloning done to remove any binding of the events
element.onkeypress = function(event){ element.onkeypress = function(event){
......
...@@ -68,6 +68,49 @@ ...@@ -68,6 +68,49 @@
{{-- For DataTables --}} {{-- For DataTables --}}
{{ Html::script(mix('js/dataTable.js')) }} {{ Html::script(mix('js/dataTable.js')) }}
<script> <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() { $(function() {
var dataTable = $('#users-table').dataTable({ var dataTable = $('#users-table').dataTable({
processing: true, processing: true,
...@@ -102,6 +145,6 @@ ...@@ -102,6 +145,6 @@
}); });
Backend.DataTableSearch.init(dataTable); Backend.DataTableSearch.init(dataTable);
}); });*/
</script> </script>
@endsection @endsection
...@@ -81,7 +81,14 @@ ...@@ -81,7 +81,14 @@
{{ Html::script(mix('js/dataTable.js')) }} {{ Html::script(mix('js/dataTable.js')) }}
<script> <script>
$(function() { (function() {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var dataTable = $('#users-table').dataTable({ var dataTable = $('#users-table').dataTable({
processing: true, processing: true,
serverSide: true, serverSide: true,
...@@ -116,6 +123,6 @@ ...@@ -116,6 +123,6 @@
}); });
Backend.DataTableSearch.init(dataTable); Backend.DataTableSearch.init(dataTable);
}); })();
</script> </script>
@endsection @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