Commit 16c987a1 by Ari Agung Prasetiyo Committed by Ari Agung Prasetiyo

penyesuaian detable

1 parent 2b0d4a71
...@@ -203,15 +203,17 @@ class DeTable(field.Field): ...@@ -203,15 +203,17 @@ class DeTable(field.Field):
class= "btn btn-warning dropdown">Filters</a> class= "btn btn-warning dropdown">Filters</a>
""" """
header_buttons.insert(0, button) header_buttons.insert(0, button)
edit_buttons = []
if allow_check: if allow_check:
button = f""" button = f"""
<input type="checkbox" class="${tableid}checkAll">All</input> <input type="checkbox" class="{tableid}checkAll form-control"> All</input>
""" """
header_buttons.insert(0, button) edit_buttons.append(button)
self.buttons = "','".join(header_buttons).replace('\n', ""). \ self.buttons = "','".join(header_buttons).replace('\n', ""). \
replace(';', ';\n') replace(';', ';\n')
self.edit_buttons = "','".join(edit_buttons).replace('\n', ""). \
replace(';', ';\n')
self.tableid = tableid self.tableid = tableid
self.scripts = ''.join(_scripts).replace(';', ";\n") self.scripts = ''.join(_scripts).replace(';', ";\n")
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
filter_columns filter_columns|field.filter_columns; filter_columns filter_columns|field.filter_columns;
filter_scripts filter_scripts|field.filter_scripts; filter_scripts filter_scripts|field.filter_scripts;
filter_form filter_form|field.filter_form; filter_form filter_form|field.filter_form;
edit_buttons edit_buttons|field.edit_buttons;
" tal:attributes="style style; class css_class; attributes|field.widget.attributes|{};" i18n:domain="detable"> " tal:attributes="style style; class css_class; attributes|field.widget.attributes|{};" i18n:domain="detable">
<header role="heading" class="txt-color-grayDark"> <header role="heading" class="txt-color-grayDark">
<h2 tal:condition="title"><i class="fa fa-fw fa-table"></i>${title}</h2> <h2 tal:condition="title"><i class="fa fa-fw fa-table"></i>${title}</h2>
...@@ -54,8 +55,9 @@ ...@@ -54,8 +55,9 @@
</div> </div>
</div> --> </div> -->
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$('.${tableid}checkAll').click(function () { $(document).on("click",'.${tableid}checkAll',function () {
if (this.checked) { if (this.checked) {
$(".${tableid}_check").prop("checked", true); $(".${tableid}_check").prop("checked", true);
} else { } else {
...@@ -134,8 +136,14 @@ ...@@ -134,8 +136,14 @@
"previous": '<span class="glyphicon glyphicon-backward"></span> ', "previous": '<span class="glyphicon glyphicon-backward"></span> ',
"next": '<span class="glyphicon glyphicon-forward"></span> ', "next": '<span class="glyphicon glyphicon-forward"></span> ',
}, },
"infoEmpty": "Menampilkan 0 sampai 0 dari 0",
"info": "Menampilkan _START_ sampai _END_ dari _TOTAL_", "info": "Menampilkan _START_ sampai _END_ dari _TOTAL_",
"lengthMenu": " _MENU_ baris " "infoFiltered": "(disaring dari _MAX_ total keseluruhan)",
"lengthMenu": " _MENU_ baris ",
"loadingRecords": "Sedang memuat...",
"processing": "Sedang memproses...",
"emptyTable": "Tidak ada data yang tersedia pada tabel ini",
"zeroRecords": "Tidak ditemukan data yang sesuai",
}; };
...@@ -234,7 +242,8 @@ ...@@ -234,7 +242,8 @@
o${tableid} = $('#${tableid}').DataTable({ o${tableid} = $('#${tableid}').DataTable({
scrollX: ${field.scroll_x}, scrollX: ${field.scroll_x},
//scrollY: ${field.scroll_y}, //scrollY: ${field.scroll_y},
dom: '<"row"<"col-md-8"<"toolbar">Bl><"col-md-4"fr>>tip', //dom: '<"row"<"col-md-8"<"toolbar">Bl><"col-md-4"fr>>tip',
dom: '<"row"<"col-md-8"<"toolbar">>><"row"<"col-md-8"Bl><"col-md-4"fr>>t<"row dt-footer"<"col-md-8" i><"col-md-4"p>>',
processing: true, processing: true,
serverSide: ${server_side}, serverSide: ${server_side},
data: param_data, data: param_data,
...@@ -269,7 +278,8 @@ ...@@ -269,7 +278,8 @@
let tb = tb_array.join(' '); let tb = tb_array.join(' ');
$("div.toolbar").html(tb); $("div.toolbar").html(tb);
$("div.toolbar").attr('style', 'display:block; float: left; margin-bottom:6px; line-height:16px;'); $("div.toolbar").attr('style', 'display:block; float: left; margin-bottom:6px; line-height:16px;');
$("div.dt-footer").attr('style','margin-left: -7px;');
$(".dataTables_scrollBody").attr('style','margin-top: -10px;');
$('#${tableid} tbody').on('click', ':checkbox', function () { $('#${tableid} tbody').on('click', ':checkbox', function () {
if (this.checked) m${tableid}CheckList.push($(this).val()); if (this.checked) m${tableid}CheckList.push($(this).val());
...@@ -294,6 +304,8 @@ ...@@ -294,6 +304,8 @@
if (code === 13) filter_table(); if (code === 13) filter_table();
}); });
$("#${tableid}_length").append('<label>&emsp;${structure:edit_buttons}</label>')
function filter_table() { function filter_table() {
$(".${tableid}-control-filter").each(function (e) { $(".${tableid}-control-filter").each(function (e) {
var col_id = $(this).attr("id"); var col_id = $(this).attr("id");
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!