Commit b705d457 by aa.gusti

perbaikan detable

1 parent 808b8a58
...@@ -430,9 +430,8 @@ class BaseView(object): ...@@ -430,9 +430,8 @@ class BaseView(object):
if k in select_list.keys(): if k in select_list.keys():
vals = select_list[k] vals = select_list[k]
for r in vals: for r in vals:
if r[0] == res[k]: if r and str(r) == str(res[k]):
res[k] = r[1] res[k] = vals[r]
""
# for k, v in d.items(): # for k, v in d.items():
# if k in url and v: # if k in url and v:
# link = "/".join([self.home, nik_url, v]) # link = "/".join([self.home, nik_url, v])
......
...@@ -428,7 +428,7 @@ class DeTable(field.Field): ...@@ -428,7 +428,7 @@ class DeTable(field.Field):
html += f'placeholder="{f.title}" {txt}/>' html += f'placeholder="{f.title}" {txt}/>'
html += '<option value="">Semua</option>' html += '<option value="">Semua</option>'
if type(wg_select_val) == list: if type(wg_select_val) == list:
wg_select_val = dict(list) wg_select_val = dict(wg_select_val)
for key in wg_select_val: for key in wg_select_val:
html += f'<option value="{key}">{wg_select_val[key]}</option>' html += f'<option value="{key}">{wg_select_val[key]}</option>'
......
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
function displayEmptyID() { function displayEmptyID() {
$("#emptyID").show(); $("#emptyID").show();
$('#emptyID').animate({ opacity: 0.8 }, 2000); $('#emptyID').animate({opacity: 0.8}, 2000);
setTimeout(function () { setTimeout(function () {
$("#emptyID").fadeTo(500, 0).slideUp(500, function () { $("#emptyID").fadeTo(500, 0).slideUp(500, function () {
$("#emptyID").hide(); $("#emptyID").hide();
...@@ -154,7 +154,7 @@ ...@@ -154,7 +154,7 @@
function render_checklist(value) { function render_checklist(value) {
return '<input type="checkbox" class="${tableid}_check" checked="' + { value } + '"></input>'; return '<input type="checkbox" class="${tableid}_check" checked="' + {value} + '"></input>';
} }
...@@ -169,12 +169,13 @@ ...@@ -169,12 +169,13 @@
} }
return render_checkbox(false); return render_checkbox(false);
} }
} else if (${tableid}Columns[co].wg_select === true) { //}
${tableid}Columns[co].render = function (value) { //else if (${tableid}Columns[co].wg_select === true) {
if (value!=null) // ${tableid}Columns[co].render = function (value) {
return ${tableid}Columns[co].wg_select_val[value]; // if (value != null)
return ""; // return ${tableid}Columns[co].wg_select_val[value];
} // return "";
// }
} else if (${tableid}Columns[co].hasOwnProperty("url")) { } else if (${tableid}Columns[co].hasOwnProperty("url")) {
let url = ${tableid}Columns[co].url; let url = ${tableid}Columns[co].url;
${tableid}Columns[co].render = function (data) { ${tableid}Columns[co].render = function (data) {
...@@ -224,16 +225,12 @@ ...@@ -224,16 +225,12 @@
let ${tableid}Params = {} let ${tableid}Params = {}
var param_ajax = ""; var param_ajax = "";
var param_data = ""; var param_data = [];
if (!${server_side}) { if (!${server_side}) {
param_data = ${data}; param_data = ${data};
param_ajax = "";
} else { } else {
param_ajax = o${tableid}Url; param_ajax = o${tableid}Url;
param_data = [];
} }
o${tableid} = $('#${tableid}').DataTable({ o${tableid} = $('#${tableid}').DataTable({
scrollX: ${field.scroll_x}, scrollX: ${field.scroll_x},
//scrollY: ${field.scroll_y}, //scrollY: ${field.scroll_y},
...@@ -294,9 +291,7 @@ ...@@ -294,9 +291,7 @@
<tal:block tal:condition="filter_columns"> <tal:block tal:condition="filter_columns">
$(".${tableid}-control-filter").on('keyup', function (e) { $(".${tableid}-control-filter").on('keyup', function (e) {
var code = e.keyCode || e.which; var code = e.keyCode || e.which;
if (code === 13) { if (code === 13) filter_table();
filter_table()
}
}); });
function filter_table() { function filter_table() {
...@@ -315,7 +310,8 @@ ...@@ -315,7 +310,8 @@
.column($(this).data('index')) .column($(this).data('index'))
.search(this.value) .search(this.value)
} }
} else if ($(this).attr("type") === 'date') { }
else if ($(this).attr("type") === 'date') {
value = this.value; value = this.value;
localStorage.setItem(col_id, value); localStorage.setItem(col_id, value);
var splitted = col_id.split('-'); var splitted = col_id.split('-');
...@@ -340,7 +336,8 @@ ...@@ -340,7 +336,8 @@
o${tableid} o${tableid}
.column($(this).data('index')) .column($(this).data('index'))
.search(min_val + '-yadcf_delim-' + max_val, true) .search(min_val + '-yadcf_delim-' + max_val, true)
} else { }
else {
col_id = this.id; col_id = this.id;
value = this.value; value = this.value;
if (value === undefined || value === null) { if (value === undefined || value === null) {
...@@ -353,6 +350,7 @@ ...@@ -353,6 +350,7 @@
.search(value); .search(value);
} }
}); });
//o${tableid}.ajax.url(o${tableid}Url).load();
o${tableid}.draw(); o${tableid}.draw();
} }
...@@ -360,7 +358,7 @@ ...@@ -360,7 +358,7 @@
console.log("Write Data Click"); console.log("Write Data Click");
var typ = $(this).attr("type"); var typ = $(this).attr("type");
if (typ === 'radio') { if (typ === 'radio') {
filter_table() filter_table();
} }
}); });
$(".${tableid}-control-filter").on('change', function (e) { $(".${tableid}-control-filter").on('change', function (e) {
...@@ -368,12 +366,14 @@ ...@@ -368,12 +366,14 @@
if (typ === "select") { if (typ === "select") {
filter_table() filter_table()
} }
var typ = $(this).attr("type").toLowerCase(); var typ = $(this).attr("type").toLowerCase();
if (typ === "date") { if (typ === "date") {
filter_table() filter_table();
} }
}); });
console.log("Read Data"); console.log("Read Data");
$(".${tableid}-control-filter").each(function (e) { $(".${tableid}-control-filter").each(function (e) {
var col_id = $(this).attr("id") var col_id = $(this).attr("id")
...@@ -391,10 +391,11 @@ ...@@ -391,10 +391,11 @@
if (value !== undefined && value !== null) if (value !== undefined && value !== null)
$(this).val(value); $(this).val(value);
} }
console.log(col_id, $(this).attr('id'), value); //console.log(col_id, $(this).attr('id'), value);
}); });
filter_table(); filter_table();
</tal:block> </tal:block>
${structure: btnscripts} ${structure: btnscripts}
${structure: filter_scripts} ${structure: filter_scripts}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!