Commit 7472c8b0 by aa.gusti

detable checklist

1 parent d6ab3bfc
...@@ -47,8 +47,14 @@ ...@@ -47,8 +47,14 @@
</div> </div>
</div> </div>
</div> </div>
<div tal:condition="allow_check"> <div class="row" tal:condition="allow_check=='true'">
<input type="checkbox" class="${tableid}checkAll">Pilih Semua <div class="form-group col-md-3">
<div class="input-group">
<input type="checkbox" class="${tableid}checkAll"/>
<span
class="input-group-addon">Pilih Semua
</span>
</div>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
$('.${tableid}checkAll').click(function () { $('.${tableid}checkAll').click(function () {
...@@ -60,11 +66,10 @@ ...@@ -60,11 +66,10 @@
$(".${tableid}_check").prop("checked", false); $(".${tableid}_check").prop("checked", false);
} }
}); });
}); });
</script> </script>
</div> </div>
</div>
<table id="${tableid}" <table id="${tableid}"
class="table table-bordered table-hover table-condensed dataTable no-footer"> class="table table-bordered table-hover table-condensed dataTable no-footer">
<thead> <thead>
...@@ -94,7 +99,7 @@ ...@@ -94,7 +99,7 @@
var o${tableid}Uri = "${url}"; var o${tableid}Uri = "${url}";
var o${tableid}Url = o${tableid}Uri + "${url_suffix}"; var o${tableid}Url = o${tableid}Uri + "${url_suffix}";
var m${tableid}ID; var m${tableid}ID;
var m${tableid}ChekList = []; var m${tableid}CheckList = [];
deform.addCallback('${tableid}', function (oid) { deform.addCallback('${tableid}', function (oid) {
// $(document).ready(function () { // $(document).ready(function () {
...@@ -145,7 +150,7 @@ ...@@ -145,7 +150,7 @@
function render_checklist(value) { function render_checklist(value) {
return '<input type="checkbox" checked="' + {value} + '"></input>'; return '<input type="checkbox" class="${tableid}_check" checked="' + {value} + '"></input>';
} }
...@@ -183,7 +188,7 @@ ...@@ -183,7 +188,7 @@
${tableid}Columns[co].render = function (id) { ${tableid}Columns[co].render = function (id) {
let result = ""; let result = "";
if (${allow_check}) { if (${allow_check}) {
result = '<input type="checkbox" class="${tableid}_check" value="' + id + '" id="${tableid}check' + id + '">&nbsp;'; result = '<input type="checkbox" class="${tableid}_check" value="' + id + '"/>&nbsp;';
} }
if (${allow_view}) if (${allow_view})
result += '<a href="${url}/' + id + '/view"><i class="fas fa-eye" aria-hidden="true" title="View"></i></a>&nbsp;'; result += '<a href="${url}/' + id + '/view"><i class="fas fa-eye" aria-hidden="true" title="View"></i></a>&nbsp;';
...@@ -251,19 +256,11 @@ ...@@ -251,19 +256,11 @@
$("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;');
$('#${tableid} tbody tr td').on('click', ':checkbox', function (event) { $('#${tableid} tbody').on('click', ':checkbox', function () {
alert("checkbox clicked"); if (this.checked) m${tableid}CheckList.push($(this).val());
if (this.checked) { else m${tableid}CheckList.splice(m${tableid}CheckList.indexOf($(this).val()), 1);
m${tableid}ChekList.push($(this).val()); });
} else {
m${tableid}CheckList.splice(m${tableid}CheckList.indexOf($(this).val()), 1);
}
console.log(m${tableid}CheckList);
})
$('#${tableid} tbody').on('click', 'tr', function () { $('#${tableid} tbody').on('click', 'tr', function () {
// alert("table clicked");
if ($(this).hasClass('selected')) { if ($(this).hasClass('selected')) {
$(this).removeClass('selected'); $(this).removeClass('selected');
m${tableid}ID = null; m${tableid}ID = null;
...@@ -272,7 +269,6 @@ ...@@ -272,7 +269,6 @@
o${tableid}.$('tr.selected').removeClass('selected'); o${tableid}.$('tr.selected').removeClass('selected');
$(this).addClass('selected'); $(this).addClass('selected');
m${tableid}ID = aData.id; m${tableid}ID = aData.id;
//console.log("m${tableid}ID", m${tableid}ID);
o${tableid}.$('tr.row_selected').removeClass('row_selected'); o${tableid}.$('tr.row_selected').removeClass('row_selected');
$(this).addClass('row_selected'); $(this).addClass('row_selected');
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!