ikinci temizlik tamamlandı
This commit is contained in:
@@ -0,0 +1,197 @@
|
||||
|
||||
<style>
|
||||
thead {
|
||||
background: #fff;
|
||||
}
|
||||
tbody td:hover {
|
||||
outline: solid 1px #33dbf9;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<table class="table table-bordered table-striped table-vcenter data-tables table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<?php foreach($columnsList AS $column) { ?>
|
||||
<th class="text-center"
|
||||
data-name="{{$column['name']}}"
|
||||
data-type="{{$column['type']}}"
|
||||
data-relation="{{json_encode_tr($column['relation'])}}"
|
||||
>{{e2($column['name'])}}</th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<?php foreach($columns AS $column) { ?>
|
||||
<th class="text-center"></th>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
|
||||
<script src="{{url("assets/admin/data-tables/fixed-header/js/dataTables.fixedHeader.min.js")}}"></script>
|
||||
<script src="{{url("assets/admin/data-tables/editor.js")}}"></script>
|
||||
|
||||
<?php // dump($columnsList) ?>
|
||||
|
||||
<script>
|
||||
var editor;
|
||||
$(document).ready(function(){
|
||||
/*
|
||||
window.setTimeout(function(){
|
||||
editor = new $.fn.dataTable.Editor( {
|
||||
ajax: "../php/staff.php",
|
||||
table: "#edit",
|
||||
fields: [ {
|
||||
label: "First name:",
|
||||
name: "first_name"
|
||||
}, {
|
||||
label: "Last name:",
|
||||
name: "last_name"
|
||||
}, {
|
||||
label: "Position:",
|
||||
name: "position"
|
||||
}, {
|
||||
label: "Office:",
|
||||
name: "office"
|
||||
}, {
|
||||
label: "Extension:",
|
||||
name: "extn"
|
||||
}, {
|
||||
label: "Start date:",
|
||||
name: "start_date",
|
||||
type: "datetime"
|
||||
}, {
|
||||
label: "Salary:",
|
||||
name: "salary"
|
||||
}
|
||||
]
|
||||
} );
|
||||
},2000);
|
||||
*/
|
||||
|
||||
var table = $('.data-tables').DataTable({
|
||||
ajax: '{{url("admin/to-json/". $tableName)}}',
|
||||
|
||||
fixedHeader: {
|
||||
header: true,
|
||||
footer: true
|
||||
},
|
||||
scrollY: "50vh",
|
||||
scrollX: true,
|
||||
/*
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
{
|
||||
text: '{{e2("Clear State")}}',
|
||||
action: function ( e, dt, node, config ) {
|
||||
table.state.clear();
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
],
|
||||
*/
|
||||
responsive: true,
|
||||
// "scrollX": true,
|
||||
stateSave: true,
|
||||
initComplete: function () {
|
||||
this.api()
|
||||
.columns()
|
||||
.every(function () {
|
||||
var column = this;
|
||||
var select = $('<select class="form-control"><option value=""></option></select>')
|
||||
.appendTo($(column.footer()).empty())
|
||||
.on('change', function () {
|
||||
var val = $.fn.dataTable.util.escapeRegex($(this).val());
|
||||
|
||||
column.search(val ? '^' + val + '$' : '', true, false).draw();
|
||||
});
|
||||
|
||||
column
|
||||
.data()
|
||||
.unique()
|
||||
.sort()
|
||||
.each(function (d, j) {
|
||||
select.append('<option value="' + d + '">' + d + '</option>');
|
||||
});
|
||||
|
||||
});
|
||||
// select.select2();
|
||||
},
|
||||
});
|
||||
|
||||
table.on("dblclick", 'tr td:first-child', function(){
|
||||
var id = $(this).text();
|
||||
location.href="?detail=" + id;
|
||||
});
|
||||
table.on( 'mouseover', 'tbody td:not(:first-child):not(.edited)', function (e) {
|
||||
init($(this));
|
||||
});
|
||||
|
||||
/*
|
||||
table.on( 'dblclick', 'tbody td:not(:first-child):not(.edited)', function (e) {
|
||||
|
||||
var that = $(this);
|
||||
var index = that.index();
|
||||
var column = $(".data-tables").find("th:eq("+index+")");
|
||||
var type = column.attr("data-type");
|
||||
var name = column.attr("data-name");
|
||||
var id = that.parent().find("td:eq(0)").text();
|
||||
var relation = JSON.parse(column.attr("data-relation"));
|
||||
|
||||
that.addClass("edited");
|
||||
|
||||
$.post('?ajax=click-edit', {
|
||||
'_token' : "{{csrf_token()}}",
|
||||
'id' : id,
|
||||
'type' : type,
|
||||
'name' : name,
|
||||
'table_name' : "{{$tableName}}",
|
||||
// 'relation' : JSON.stringify(relation),
|
||||
}, function(d) {
|
||||
that.html(d);
|
||||
|
||||
});
|
||||
|
||||
|
||||
} );
|
||||
*/
|
||||
table.on( 'dblclick', 'tbody td:not(:first-child):not(.edited)', function (e) {
|
||||
|
||||
var that = $(this);
|
||||
var index = that.index();
|
||||
var column = $(".data-tables").find("th:eq("+index+")");
|
||||
var type = column.attr("data-type");
|
||||
var name = column.attr("data-name");
|
||||
var id = that.parent().find("td:eq(0)").text();
|
||||
var relation = JSON.parse(column.attr("data-relation"));
|
||||
|
||||
that.addClass("edited");
|
||||
// editor.inline( this );
|
||||
|
||||
} );
|
||||
|
||||
|
||||
$(".dt-button").addClass("btn");
|
||||
$(".dt-button").addClass("btn-primary");
|
||||
|
||||
var clearStateButton = $('<div class="btn-block-option" id="clear-state" title="{{e2("Clear Table State")}}"><i class="fa fa-refresh"></i></div>');
|
||||
|
||||
$(".block-options").append(clearStateButton);
|
||||
|
||||
$(".block-options").on("click", "#clear-state", function() {
|
||||
console.log("ok");
|
||||
table.state.clear();
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user