Commit f2311403 authored by Kevin Yumang's avatar Kevin Yumang

SERV-2286 - datatable attributes modification

parent e0aeeed6
.DatatableFader {
height:0px;
opacity:0;
overflow-y: hidden;
}
\ No newline at end of file
...@@ -25,34 +25,42 @@ function limitless_init_datatable() { ...@@ -25,34 +25,42 @@ function limitless_init_datatable() {
// count table // count table
DatatableCounter++; DatatableCounter++;
var currentClass = $(this).attr('class'); // element
let elementTable = $(this);
var currentClass = elementTable.attr('class');
currentClass = currentClass.replace('LimitlessTable',''); currentClass = currentClass.replace('LimitlessTable','');
// create replacement // create replacement
var NewHtml = '' + var NewHtml = '' +
'<div id="DatatableFader' + DatatableCounter + '" class="DatatableFader" style="height:0px; opacity:0; overflow-y: hidden;">' + '<div id="DatatableFader' + DatatableCounter + '" class="DatatableFader">' +
'<table id="Datatable' + DatatableCounter + '" class="display table datatable ' + currentClass + '">' + '<table id="Datatable' + DatatableCounter + '" class="display table datatable ' + currentClass + '">' +
$(this).html() + elementTable.html() +
'</table>' + '</table>' +
'</div>'; '</div>';
// transport code to html // transport code to html
$(this).replaceWith(NewHtml); elementTable.replaceWith(NewHtml);
// render setup parameter // render setup parameter
var counter = 0; var counter = 0;
var sort = []; var sort = [];
var orderable = []; var orderable = [];
$('#Datatable' + DatatableCounter).find('th').each(function () { $('#Datatable' + DatatableCounter).find('th').each(function () {
let tableHeaderElement = $(this);
console.log(tableHeaderElement);
// define sort // define sort
if ($(this).attr('Sort') != undefined) { if (tableHeaderElement.attr('Sort') != undefined) {
sort = [ sort = [
[counter, $(this).attr('Sort')] [counter, tableHeaderElement.attr('Sort')]
]; ];
} }
// orderable // orderable
if ($(this).attr('Sortable') == "false") { if (tableHeaderElement.attr('Sortable') == "false") {
orderable.push({ orderable.push({
"orderable": false, "orderable": false,
"targets": counter "targets": counter
...@@ -60,7 +68,7 @@ function limitless_init_datatable() { ...@@ -60,7 +68,7 @@ function limitless_init_datatable() {
} }
// searchable // searchable
if ($(this).attr('Searchable') != "true") { if (tableHeaderElement.attr('Searchable') != undefined && tableHeaderElement.attr('Searchable') == "false") {
orderable.push({ orderable.push({
"searchable": false, "searchable": false,
"targets": counter "targets": counter
...@@ -73,7 +81,7 @@ function limitless_init_datatable() { ...@@ -73,7 +81,7 @@ function limitless_init_datatable() {
}); });
// rows // rows
var rows = $(this).attr('rows'); var rows = elementTable.attr('rows');
if (rows == undefined) { if (rows == undefined) {
rows = 10; rows = 10;
} }
...@@ -85,7 +93,7 @@ function limitless_init_datatable() { ...@@ -85,7 +93,7 @@ function limitless_init_datatable() {
var Complex = false; var Complex = false;
} }
if($('table').hasClass('downloadbuttons')){ if(elementTable.hasClass('downloadbuttons')){
$(".dt-buttons").removeClass('hideBtn'); $(".dt-buttons").removeClass('hideBtn');
$(".dt-buttons").addClass('showBtn'); $(".dt-buttons").addClass('showBtn');
......
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
{ {
$this->assetAllocation = [ $this->assetAllocation = [
'Limitless::DatatableStart' => [ 'Limitless::DatatableStart' => [
'Attachments/datatables.js', 'Attachments/datatables.init.js',
'Attachments/datatables.init.css',
'Attachments/jquery.datatables.js', 'Attachments/jquery.datatables.js',
] ]
]; ];
...@@ -74,7 +75,8 @@ ...@@ -74,7 +75,8 @@
public function datatableStart($parameters) public function datatableStart($parameters)
{ {
return View('Limitless::Datatable.Start') return View('Limitless::Datatable.Start')
->withExtra( ($parameters['extra'] ?? []) ); ->withExtra($parameters['extra'] ?? [])
->withRows($parameters['rows'] ?? null);
} }
......
...@@ -68,12 +68,12 @@ ...@@ -68,12 +68,12 @@
@Limitless::DatatableStart([ 'extra' => ['class' => 'table table-striped']]) @Limitless::DatatableStart([ 'extra' => ['class' => 'table table-striped']])
<thead> <thead>
<th Searchable="true" Sort="asc"> Name </th> <th Sortable=false> Name </th>
<th Searchable="true"> Position </th> <th> Position </th>
<th Searchable="true" Sortable="true"> Office </th> <th> Office </th>
<th Sortable="true"> Age </th> <th> Age </th>
<th Sortable="true"> Start date </th> <th> Start date </th>
<th Sortable="true"> Salary </th> <th> Salary </th>
</thead> </thead>
<tbody> <tbody>
......
...@@ -9,4 +9,7 @@ ...@@ -9,4 +9,7 @@
{{$k}}="{{$v}}" {{$k}}="{{$v}}"
@endforeach @endforeach
@if($rows) rows='{{ $rows }}' @endif
class="table LimitlessTable" hidden> class="table LimitlessTable" hidden>
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