2015-05-10 21:02:35 +02:00
|
|
|
<table class="table table-striped data-table {{ $class = str_random(8) }}">
|
2015-03-16 22:45:25 +01:00
|
|
|
<colgroup>
|
|
|
|
@for ($i = 0; $i < count($columns); $i++)
|
|
|
|
<col class="con{{ $i }}" />
|
|
|
|
@endfor
|
|
|
|
</colgroup>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
@foreach($columns as $i => $c)
|
2016-03-02 14:36:42 +01:00
|
|
|
<th align="center" valign="middle" class="head{{ $i }}"
|
2015-03-16 22:45:25 +01:00
|
|
|
@if ($c == 'checkbox')
|
2016-03-02 14:36:42 +01:00
|
|
|
style="width:20px"
|
2015-03-16 22:45:25 +01:00
|
|
|
@endif
|
|
|
|
>
|
|
|
|
@if ($c == 'checkbox' && $hasCheckboxes = true)
|
|
|
|
<input type="checkbox" class="selectAll"/>
|
|
|
|
@else
|
|
|
|
{{ $c }}
|
|
|
|
@endif
|
|
|
|
</th>
|
|
|
|
@endforeach
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
@foreach($data as $d)
|
|
|
|
<tr>
|
|
|
|
@foreach($d as $dd)
|
|
|
|
<td>{{ $dd }}</td>
|
|
|
|
@endforeach
|
|
|
|
</tr>
|
|
|
|
@endforeach
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<script type="text/javascript">
|
2016-11-24 10:22:37 +01:00
|
|
|
@if (isset($values['clientId']) && $values['clientId'])
|
2015-11-29 17:00:50 +01:00
|
|
|
window.load_{{ $values['entityType'] }} = function load_{{ $values['entityType'] }}() {
|
|
|
|
load_{{ $class }}();
|
|
|
|
}
|
|
|
|
@else
|
|
|
|
jQuery(document).ready(function(){
|
|
|
|
load_{{ $class }}();
|
|
|
|
});
|
|
|
|
@endif
|
|
|
|
|
2016-02-18 19:14:48 +01:00
|
|
|
function refreshDatatable() {
|
|
|
|
window.dataTable.api().ajax.reload();
|
|
|
|
}
|
|
|
|
|
2015-11-29 17:00:50 +01:00
|
|
|
function load_{{ $class }}() {
|
2016-02-18 19:14:48 +01:00
|
|
|
window.dataTable = jQuery('.{{ $class }}').dataTable({
|
2016-10-09 16:18:03 +02:00
|
|
|
"stateSave": true,
|
|
|
|
"stateDuration": 0,
|
2016-03-02 14:36:42 +01:00
|
|
|
"fnRowCallback": function(row, data) {
|
2015-03-16 22:45:25 +01:00
|
|
|
if (data[0].indexOf('ENTITY_DELETED') > 0) {
|
|
|
|
$(row).addClass('entityDeleted');
|
|
|
|
}
|
|
|
|
if (data[0].indexOf('ENTITY_ARCHIVED') > 0) {
|
|
|
|
$(row).addClass('entityArchived');
|
|
|
|
}
|
|
|
|
},
|
2015-05-10 21:02:35 +02:00
|
|
|
"bAutoWidth": false,
|
2016-03-02 14:36:42 +01:00
|
|
|
"aoColumnDefs": [
|
2016-12-25 22:43:57 +01:00
|
|
|
@if (isset($hasCheckboxes) && $hasCheckboxes)
|
|
|
|
// Disable sorting on the first column
|
2016-02-01 14:58:52 +01:00
|
|
|
{
|
|
|
|
'bSortable': false,
|
|
|
|
'aTargets': [ 0, {{ count($columns) - 1 }} ]
|
|
|
|
},
|
2016-12-25 22:43:57 +01:00
|
|
|
@endif
|
2016-02-01 14:58:52 +01:00
|
|
|
{
|
|
|
|
'sClass': 'right',
|
|
|
|
'aTargets': {{ isset($values['rightAlign']) ? json_encode($values['rightAlign']) : '[]' }}
|
|
|
|
}
|
|
|
|
],
|
2015-03-16 22:45:25 +01:00
|
|
|
@foreach ($options as $k => $o)
|
2015-04-02 06:09:32 +02:00
|
|
|
{!! json_encode($k) !!}: {!! json_encode($o) !!},
|
2015-03-16 22:45:25 +01:00
|
|
|
@endforeach
|
|
|
|
@foreach ($callbacks as $k => $o)
|
2015-04-02 06:09:32 +02:00
|
|
|
{!! json_encode($k) !!}: {!! $o !!},
|
2015-03-16 22:45:25 +01:00
|
|
|
@endforeach
|
|
|
|
"fnDrawCallback": function(oSettings) {
|
2016-11-25 13:45:37 +01:00
|
|
|
@if (isset($values['entityType']))
|
|
|
|
if (window.onDatatableReady_{{ $values['entityType'] }}) {
|
|
|
|
window.onDatatableReady_{{ $values['entityType'] }}();
|
2016-11-25 15:02:39 +01:00
|
|
|
} else if (window.onDatatableReady) {
|
2016-11-25 13:45:37 +01:00
|
|
|
window.onDatatableReady();
|
|
|
|
}
|
|
|
|
@else
|
|
|
|
if (window.onDatatableReady) {
|
|
|
|
window.onDatatableReady();
|
|
|
|
}
|
|
|
|
@endif
|
2016-10-18 20:15:08 +02:00
|
|
|
},
|
|
|
|
"stateLoadParams": function (settings, data) {
|
|
|
|
// don't save filter to local storage
|
|
|
|
data.search.search = "";
|
2017-03-28 20:09:53 +02:00
|
|
|
// always start on first page of results
|
|
|
|
data.start = 0;
|
2015-03-16 22:45:25 +01:00
|
|
|
}
|
|
|
|
});
|
2015-11-29 17:00:50 +01:00
|
|
|
}
|
2016-10-09 16:18:03 +02:00
|
|
|
</script>
|