Commit 59ce6bc7 by aa.gusti

datatable date

1 parent 8ec0c6d1
......@@ -500,6 +500,7 @@ def add_view_config(config, module, view_name):
renderer=renderers)
except Exception as e:
log.error(str(e))
log.error(dict(row.__dict__))
config.scan('.')
......
......@@ -46,7 +46,10 @@ def routes_callback(typ, **kwargs):
return None
value = splited_last
elif field == "class_view":
if data["def_func"] == "list" and not data["class_view"]:
if data["def_func"] == "list" and not data["class_view"] \
or splited_last not in ["add", "edit", "delete", "view", "act", "report"]:
log.debug(splited[-1:])
log.debug(data)
return "_".join(splited[1:])
if splited_last == "menu":
......
......@@ -136,7 +136,7 @@ class BaseView(object):
self.list_buttons = (btn_add, btn_close)
self.columns = None
self.form_params = dict(scripts="")
self.list_url = ''
self.list_url = []
self.list_route = ''
self.list_schema = colander.Schema
self.allow_view = True
......@@ -145,7 +145,9 @@ class BaseView(object):
self.allow_post = False
self.allow_unpost = False
self.state_save = False
self.server_side = True
self.list_form = None
self.form_list = None
self.filter_columns = False
self.form_scripts = """
......@@ -243,16 +245,18 @@ class BaseView(object):
allow_unpost = kwargs.get("allow_unpost", self.allow_unpost)
state_save = kwargs.get("state_save", self.state_save)
filter_columns = kwargs.get("filter_columns", self.filter_columns)
server_side = kwargs.get("server_side", self.server_side)
schema = self.list_schema()
schema = schema.bind(request=self.req)
list_url = kwargs.get("list_url", None)
new_buttons = kwargs.get("new_buttons")
if not new_buttons:
new_buttons = self.new_buttons
if not list_url:
list_url = kwargs.get("list_url", self.list_url)
if not list_url and self.list_route:
list_url = self.req.route_url(self.list_route)
action_suffix = kwargs.get("action_suffix", "/grid/act")
list_url = list_url and list_url[0:1] != "/" and "/" + list_url or list_url
action_suffix = list_url and kwargs.get("action_suffix", "/grid/act") or None
table = DeTable(schema,
action=list_url,
action_suffix=action_suffix,
......@@ -266,9 +270,14 @@ class BaseView(object):
state_save=state_save,
new_buttons=new_buttons,
filter_columns=filter_columns,
server_side=server_side
)
resources = table.get_widget_resources()
# resources=dict(css="", js="")
if kwargs.get("is_object"):
return dict(form=table, scripts="", css=resources["css"],
js=resources["js"])
return dict(form=table.render(), scripts="", css=resources["css"],
js=resources["js"])
......@@ -294,9 +303,13 @@ class BaseView(object):
def get_list(self, **kwargs):
url = []
select_list = {}
list_schema = kwargs.get("list_schema")
if not list_schema:
list_schema = self.list_schema and self.list_schema or self.form_list
if not self.columns:
columns = []
for d in self.list_schema():
for d in list_schema():
global_search = True
search_method = hasattr(d, "search_method") \
and getattr(d, "search_method") or "string_contains"
......@@ -406,11 +419,17 @@ class BaseView(object):
def next_edit(self, form, **kwargs):
return self.route_list(**kwargs)
def returned_form(self, form, table, **kwargs):
def returned_form(self, form, table=None, **kwargs):
resources = form.get_widget_resources()
readonly = "readonly" in kwargs and kwargs["readonly"] or False
kwargs["readonly"] = readonly
is_object = kwargs.get("is_object", self.is_object)
if dict == type(table):
resources["js"].extend(set(table["js"]) - set(resources["js"]))
resources["css"].extend(set(table["css"]) - set(resources["css"]))
table = table["form"]
# resources["js"] = list(resources["js"])
# resources["css"] = list(resources["css"])
if is_object:
return dict(form=form,
table=table and table.render() or None,
......@@ -566,10 +585,10 @@ class BaseView(object):
def view_add(self, **kwargs):
# bindings = self.get_bindings()
form = self.get_form(self.add_schema, **kwargs)
table = self.get_item_table(**kwargs)
resources = form.get_widget_resources()
is_object = kwargs.get("is_object", self.is_object)
kwargs["is_object"] = is_object
table = self.get_item_table(**kwargs)
if self.req.POST:
if 'save' in self.req.POST:
controls = self.req.POST.items()
......@@ -657,7 +676,11 @@ class BaseView(object):
return d
def get_item_table(self, row=None, **kwargs):
return None
if not self.form_list:
return None
self.list_schema = self.form_list
kwargs["is_object"] = True
return self.view_list(**kwargs)
def before_edit(self, form):
"""
......@@ -748,6 +771,7 @@ class BaseView(object):
form = self.get_form(
self.edit_schema, buttons=(btn_delete, btn_cancel))
table = self.get_item_table(row)
resources = form.get_widget_resources()
form.set_appstruct(self.get_values(row))
kwargs["readonly"] = True
......
......@@ -140,7 +140,12 @@ class ListSchema(colander.Schema):
path = colander.SchemaNode(
colander.String(), title='Path',
searchable=True)
template = colander.SchemaNode(
class_view = colander.SchemaNode(
colander.String(),
searchable=False,
global_search=False,
)
def_func = colander.SchemaNode(
colander.String(),
searchable=False,
global_search=False,
......
......@@ -107,7 +107,7 @@ class DeTable(field.Field):
filters='true',
paginates='true',
params="",
server_side='true',
server_side=True,
state_save=True,
data=[],
allow_edit=True,
......@@ -123,6 +123,7 @@ class DeTable(field.Field):
self.rows = kw.get("rows")
self.action = action
self.tableid = tableid
self.data = data
new_buttons = kw.get("new_buttons") or ()
......@@ -192,8 +193,7 @@ class DeTable(field.Field):
table_widget = widget.TableWidget()
self.widget = table_widget
self.server_side = server_side
self.server_side = json.dumps(server_side)
self.data = data
columns = []
headers = []
......@@ -236,10 +236,13 @@ class DeTable(field.Field):
if isinstance(f.widget, deform.widget.HiddenWidget):
d["visible"] = False
if isinstance(f.widget, deform.widget.CheckboxWidget):
elif isinstance(f.widget, deform.widget.CheckboxWidget):
d.update(self.widget_checkbox(f))
elif isinstance(f.widget, deform.widget.SelectWidget):
d.update(self.widget_select(f))
else:
d["checkbox"] = False
d["wg_checkbox"] = False
d["wg_select"] = False
if hasattr(f, "url"):
url = f.url
d["render"] = """
......@@ -294,7 +297,6 @@ class DeTable(field.Field):
# cols2.append(data)
filter_scripts = self.get_filter_scripts(f)
self.filter_scripts = filter_scripts
self.filter_form = filter_form
......@@ -313,8 +315,8 @@ class DeTable(field.Field):
def widget_checkbox(self, column):
d = {}
d["checkbox"] = True
d["check_val"] = [column.widget.true_val, column.widget.false_val]
d["wg_checkbox"] = True
d["wg_checkbox_val"] = [column.widget.true_val, column.widget.false_val]
d["className"] = "text-center"
d["width"] = "30pt"
# d["render"] = """
......@@ -329,6 +331,16 @@ class DeTable(field.Field):
return d
def widget_select(self, column):
d = {}
d["wg_select"] = True
d["wg_select_val"] = column.widget.values
if column.widget.values:
for val in column.widget.values:
if hasattr(column, f"color_{val}"):
d[f"color_{val}"] = getattr(column, f"color_{val}")
return d
def action_url(self, f):
act = ""
if self.allow_view:
......@@ -365,8 +377,8 @@ class DeTable(field.Field):
txt = f'id="{col_id}" data-index={field_index} '
html += '<div class="form-group">'
if isinstance(f.widget, deform.widget.CheckboxWidget):
check_val = [f.widget.true_val, f.widget.false_val]
radio_val = [["", 'Semua'], [check_val[0], 'Aktif'], [check_val[1], 'Pasif']]
wg_check_val = [f.widget.true_val, f.widget.false_val]
radio_val = [["", 'Semua'], [wg_check_val[0], 'Aktif'], [wg_check_val[1], 'Pasif']]
html += '<label class="" for="' + col_id + '">' + f.title + '</label>'
html += '<div class="input-group" id="' + col_id + '">'
for rdo in range(len(radio_val)):
......@@ -381,26 +393,43 @@ class DeTable(field.Field):
html += f'{radio_val[rdo][1]}</label>'
html += '</label>'
html += '</div>'
# elif isinstance(f.typ, colander.Date):
# requirements = f.widget.requirements
# for requirement in requirements:
# if type(requirement) == dict and "js" in requirement:
# for req in requirement:
#
# html += f'<input type="text" class="form-control {self.tableid}-control-filter hasDatePicker"'
# html += f'placeholder="{f.title}" {txt}/>'
# html += """
# <script type="text/javascript">
# deform.addCallback(
# '%s',
# function deform_cb(oid) {
# $('#'+oid).datepicker();
# }
# );
# </script>
# """ % self.tableid
elif isinstance(f.widget, deform.widget.SelectWidget):
wg_select_val = f.widget.values
html += f'<select class="form-control {self.tableid}-control-filter"'
html += f'placeholder="{f.title}" {txt}/>'
html += '<option value="">Semua</option>'
for key in wg_select_val:
html += f'<option value="{key}">{wg_select_val[key]}</option>'
html += '</select>'
elif isinstance(f.typ, colander.Date):
html += f'<div class="form-group" {txt}>'
html += f'<div class="input-group">'
html += f'<span class="input-group-addon">{f.title}</span>'
html += f'<span class="input-group-addon"><input type="date" class="form-control {self.tableid}-control-filter hasDatePicker"'
html += f'data-index={field_index} placeholder="{f.title} Awal" '
html += f'name="{col_id}" id="{col_id}-min"/></span>'
html += f'<span class="input-group-addon"><input type="date" class="form-control {self.tableid}-control-filter hasDatePicker"'
html += f'data-index={field_index} placeholder="{f.title} Akhir" '
html += f'name="{col_id}" id="{col_id}-max" /></span>'
html += f'</div>'
html += f'</div>'
# html += """
# <script type="text/javascript">
# deform.addCallback(
# '%s',
# function deform_cb(oid) {
# $('#'+oid).datepicker();
# }
# );
# </script>
# """ % self.tableid
# requirements = f.widget.requirements
# for requirement in requirements:
# if type(requirement) == dict and "js" in requirement:
# for req in requirement:
#
else:
html += f'<input type="text" class="form-control {self.tableid}-control-filter"'
html += f'placeholder="{f.title}" {txt}/>'
......@@ -410,6 +439,7 @@ class DeTable(field.Field):
def get_filter_scripts(self, f):
return ""
"""
for (let co in ${tableid}Columns) {
if (${tableid}Columns[co].checkbox === true) {
......
......@@ -40,7 +40,7 @@
<div role="content">
<div class="widget-body">
<div class="row" tal:condition="filter_columns" >
<div id="${tableid}-form-filter-container" class="col-md-6">
<div id="${tableid}-form-filter-container" class="col-md-3">
<div id="${tableid}-form-filter" class="collapse">
${structure:filter_form}
</div>
......@@ -77,265 +77,272 @@
var o${tableid}Url = o${tableid}Uri + "${url_suffix}";
var m${tableid}ID;
deform.addCallback('${tableid}', function (oid) {
function displayEmptyID() {
$("#emptyID").show();
$('#emptyID').animate({opacity: 0.8}, 2000);
setTimeout(function () {
$("#emptyID").fadeTo(500, 0).slideUp(500, function () {
$("#emptyID").hide();
});
}
, 4000);
}
function displayEmptyID() {
$("#emptyID").show();
$('#emptyID').animate({opacity: 0.8}, 2000);
setTimeout(function () {
$("#emptyID").fadeTo(500, 0).slideUp(500, function () {
$("#emptyID").hide();
});
}
, 4000);
}
let tb_array = [
'<div class="btn-group pull-left">',
'${structure:buttons}',
' &nbsp;',
'</div>',
]
let tb_array = [
'<div class="btn-group pull-left">',
'${structure:buttons}',
' &nbsp;',
'</div>',
]
let ${tableid}Language = {
"search": "Cari: ",
"paginate": {
"first": '<span class="glyphicon glyphicon-step-backward"></span> ',
"last": '<span class="glyphicon glyphicon glyphicon-step-forward"></span> ',
"previous": '<span class="glyphicon glyphicon-backward"></span> ',
"next": '<span class="glyphicon glyphicon-forward"></span> ',
},
"lengthMenu": " _MENU_ baris "
};
let ${tableid}Language = {
"search": "Cari: ",
"paginate": {
"first": '<span class="glyphicon glyphicon-step-backward"></span> ',
"last": '<span class="glyphicon glyphicon glyphicon-step-forward"></span> ',
"previous": '<span class="glyphicon glyphicon-backward"></span> ',
"next": '<span class="glyphicon glyphicon-forward"></span> ',
},
"info": "Menampilkan _START_ sampai _END_ dari _TOTAL_",
"lengthMenu": " _MENU_ baris "
};
let ${tableid}Columns = ${structure: columns};
let ${tableid}Columns = ${structure: columns};
function render_checkbox(value) {
if (value === true) {
return '<i class="fas fa-check-square" aria-hidden="true">';
}
if (value === false) {
return '<i class="fas fa-minus-square" aria-hidden="true">';
//'Archived';
}
return value;
}
function render_checkbox(value) {
if (value === true) {
return '<i class="fas fa-check-square" aria-hidden="true">';
}
if (value === false) {
return '<i class="fas fa-minus-square" aria-hidden="true">';
//'Archived';
}
return value;
}
function render_checklist(value) {
function render_checklist(value) {
return '<input type="checkbox" checked="' + {value} + '"></input>';
}
return '<input type="checkbox" checked="' + {value} + '"></input>';
}
for (let co in ${tableid}Columns) {
if (${tableid}Columns[co].checkbox === true) {
${tableid}Columns[co].render = function (value) {
if (typeof value === "string" && value.length > 0) {
return render_checkbox(value)
}
if (["", false, 0, null].indexOf(value) === -1) {
return render_checkbox(true);
}
return render_checkbox(false);
}
} else if (${tableid}Columns[co].hasOwnProperty("url")) {
let url = ${tableid}Columns[co].url;
${tableid}Columns[co].render = function (data) {
let result = "No Data"
if (data != null) {
result = '<a href="' + url + data + '" target="_blank">Link</a>&nbsp;';
}
return result;
}
} else if (${tableid}Columns[co].data === "id" && ${tableid}Columns[co].action === true) {
${tableid}Columns[co].render = function (id) {
let result = ""
if (${allow_view}) {
result = '<a href="${url}/' + id + '/view"><i class="fas fa-eye" aria-hidden="true" title="View"></i></a>&nbsp;';
}
if (${allow_edit}) {
result += '<a href="${url}/' + id + '/edit"><i class="fas fa-edit" aria-hidden="true" title="Edit"></i></a>&nbsp;'
}
if (${allow_delete}) {
result += '<a href="${url}/' + id + '/delete"><i class="fas fa-trash" aria-hidden="true" title="Delete"></i></a>';
}
if (${allow_post}) {
result += '<a href="${url}/' + id + '/post"><i class="fas fa-signs-post" aria-hidden="true" title="Post"></i></a>';
}
if (${allow_unpost}) {
result += '<a href="${url}/' + id + '/unpost"><i class="fas fa-delete-left" aria-hidden="true" title="Unpost"></i></a>';
}
return result;
}
//columns[1].order = "order_asc";
for (let co in ${tableid}Columns) {
if (${tableid}Columns[co].wg_checkbox === true) {
${tableid}Columns[co].render = function (value) {
if (typeof value === "string" && value.length > 0) {
return render_checkbox(value)
}
if (["", false, 0, null].indexOf(value) === -1) {
return render_checkbox(true);
}
return render_checkbox(false);
}
let ${tableid}Params = {
dom: '<"row"<"col-md-8"<"toolbar">Bl><"col-md-4"fr>>tip',
processing: true,
serverSide: ${server_side},
stateSave: ${state_save},
scrollCollapse: true,
sort: ${sorts},
info: false,
filter: ${filters},
autoWidth: false,
paginate: ${paginates},
paginationType: "full_numbers",
order: [],
lengthMenu: [
[10, 25, 50, 100],
[10, 25, 50, 100]
],
pageLength: 25,
columns: ${tableid}Columns,
language: ${tableid}Language,
initComplete: function () {
$('.dataTables_filter input').unbind()
.bind('keyup', function (e) {
var code = e.keyCode || e.which;
if (code === 13) {
o${tableid}.search(this.value).draw();
}
});
} else if (${tableid}Columns[co].wg_select === true) {
${tableid}Columns[co].render = function (value) {
// if (value === 0) {
// o${tableid}.$('tr.selected').bgColor(${tableid}Columns[co].get("color_" + value));
// }
// if (${tableid}Columns[co].hasOwnProperty("color_" + value)) {
//
// }
return ${tableid}Columns[co].wg_select_val[value];
}
} else if (${tableid}Columns[co].hasOwnProperty("url")) {
let url = ${tableid}Columns[co].url;
${tableid}Columns[co].render = function (data) {
let result = "No Data"
if (data != null) {
result = '<a href="' + url + data + '" target="_blank">Link</a>&nbsp;';
}
return result;
}
if (!${server_side}) {
${tableid}Params.data = ${data};
} else {
${tableid}Params.ajax = o${tableid}Url;
} else if (${tableid}Columns[co].data === "id" && ${tableid}Columns[co].action === true) {
${tableid}Columns[co].render = function (id) {
let result = ""
if (${allow_view}) {
result = '<a href="${url}/' + id + '/view"><i class="fas fa-eye" aria-hidden="true" title="View"></i></a>&nbsp;';
}
if (${allow_edit}) {
result += '<a href="${url}/' + id + '/edit"><i class="fas fa-edit" aria-hidden="true" title="Edit"></i></a>&nbsp;'
}
if (${allow_delete}) {
result += '<a href="${url}/' + id + '/delete"><i class="fas fa-trash" aria-hidden="true" title="Delete"></i></a>';
}
if (${allow_post}) {
result += '<a href="${url}/' + id + '/post"><i class="fas fa-signs-post" aria-hidden="true" title="Post"></i></a>';
}
if (${allow_unpost}) {
result += '<a href="${url}/' + id + '/unpost"><i class="fas fa-delete-left" aria-hidden="true" title="Unpost"></i></a>';
}
return result;
}
//columns[1].order = "order_asc";
}
}
//<talblock talcondition="filter_columns">
//console.log(${tableid}Columns);
//var html = "";
//for (let co in ${tableid}Columns) {
// var col = ${tableid}Columns[co];
// if (col.searchable === true) {
// var col_id = "${tableid}-" + col.data;
// var col_val = localStorage.getItem(col_id);
// if (col_val === null || col_val === undefined) {
// col_val = "";
// }
// var txt = 'id="' + col_id + '" data-index="' + co + '" value="' + col_val + '"';
//
// html += '<div class="form-group">';
// if (col.checkbox === true) {
// var radioVal = [["", 'Semua'], [col.check_val[0], 'Aktif'], [col.check_val[1], 'Pasif']];
// html += '<label class="" for="' + col_id + '">' + col.title + '</label>';
// html += '<div class="input-group" id="' + col_id + '">';
// for (var rdo = 0; rdo < radioVal.length; rdo++) {
// var selected = (col_val === radioVal[rdo][0]) ? "checked" : "";
// txt = 'id="' + col_id + '-' + radioVal[rdo][0] + '" ' +
// 'class="${tableid}-control-filter" data-index="' + co + '"' +
// 'name="' + col_id + '" value="' + radioVal[rdo][0] + '" '+selected;
//
// html += '<label class="radio-inline">';
// html += '<input type="radio" ' + txt + '/>';
// html += '<label for="' + col_id + '-' + radioVal[rdo][0] + '">' + radioVal[rdo][1] + '</label>';
// html += '</label>';
// }
// html += '</div>';
// } else
// html += '<input type="text" class="form-control ' + "${tableid}" + '-control-filter" placeholder="' + col.title + '" ' + txt + '/>';
// html += '</div>';
// }
//}
let ${tableid}Params = {
dom: '<"row"<"col-md-8"<"toolbar">Bl><"col-md-4"fr>>tip',
processing: true,
serverSide: ${server_side},
stateSave: ${state_save},
scrollCollapse: true,
sort: ${sorts},
info: true,
filter: ${filters},
autoWidth: false,
paginate: ${paginates},
paginationType: "full_numbers",
order: [],
lengthMenu: [
[10, 25, 50, 100],
[10, 25, 50, 100]
],
pageLength: 25,
columns: ${tableid}Columns,
language: ${tableid}Language,
initComplete: function () {
$('.dataTables_filter input').unbind()
.bind('keyup', function (e) {
var code = e.keyCode || e.which;
if (code === 13) {
o${tableid}.search(this.value).draw();
}
});
}
}
${structure: filter_scripts}
if (!${server_side}) {
${tableid}Params.data = ${data};
} else {
${tableid}Params.ajax = o${tableid}Url;
}
o${tableid} = $('#${tableid}').DataTable(${tableid}Params);
${structure: filter_scripts}
let tb = tb_array.join(' ');
$("div.toolbar").html(tb);
$("div.toolbar").attr('style', 'display:block; float: left; margin-bottom:6px; line-height:16px;');
$('#${tableid} tbody').on('click', 'tr', function () {
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
m${tableid}ID = null;
} else {
let aData = o${tableid}.row(this).data();
o${tableid}.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
m${tableid}ID = aData.id;
//console.log("m${tableid}ID", m${tableid}ID);
o${tableid}.$('tr.row_selected').removeClass('row_selected');
$(this).addClass('row_selected');
}
});
o${tableid} = $('#${tableid}').DataTable(${tableid}Params);
$(".${tableid}-control-filter").on('keyup', function (e) {
var code = e.keyCode || e.which;
if (code === 13) {
filter_table()
}
});
let tb = tb_array.join(' ');
$("div.toolbar").html(tb);
$("div.toolbar").attr('style', 'display:block; float: left; margin-bottom:6px; line-height:16px;');
$('#${tableid} tbody').on('click', 'tr', function () {
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
m${tableid}ID = null;
} else {
let aData = o${tableid}.row(this).data();
o${tableid}.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
m${tableid}ID = aData.id;
//console.log("m${tableid}ID", m${tableid}ID);
o${tableid}.$('tr.row_selected').removeClass('row_selected');
$(this).addClass('row_selected');
}
});
function filter_table() {
$(".${tableid}-control-filter").each(function (e) {
var col_id = $(this).attr("id")
var value;
if ($(this).attr("type") === 'radio') {
col_id = $(this).attr('id').split("-");
col_id.length = 2;
col_id = col_id.join("-");
value = this.value;
if (this.checked) {
console.log(col_id, $(this).attr('id'), value, this.checked);
localStorage.setItem(col_id, value);
o${tableid}
.column($(this).data('index'))
.search(this.value)
}
} else {
col_id = this.id;
value = this.value;
if (value === undefined || value === null) {
value = "";
}
console.log(col_id, $(this).attr('id'), value, $(this).data('index'));
localStorage.setItem(col_id, value);
o${tableid}
.column($(this).data('index'))
.search(value);
}
});
o${tableid}.draw();
}
$(".${tableid}-control-filter").on('keyup', function (e) {
var code = e.keyCode || e.which;
if (code === 13) {
filter_table()
}
});
$(".${tableid}-control-filter").on('click', function (e) {
console.log("Write Data Click");
if ($(this).attr("type") === 'radio') {
filter_table()
function filter_table() {
$(".${tableid}-control-filter").each(function (e) {
var col_id = $(this).attr("id");
var value;
if ($(this).attr("type") === 'radio') {
col_id = $(this).attr('id').split("-");
col_id.length = 2;
col_id = col_id.join("-");
value = this.value;
if (this.checked) {
console.log(col_id, $(this).attr('id'), value, this.checked);
localStorage.setItem(col_id, value);
o${tableid}
.column($(this).data('index'))
.search(this.value)
}
});
console.log("Read Data");
$(".${tableid}-control-filter").each(function (e) {
var col_id = $(this).attr("id")
var value;
if ($(this).attr("type") === 'radio') {
col_id = $(this).attr('id').split("-");
col_id.length = 2;
col_id = col_id.join("-");
value = localStorage.getItem(col_id);
if (value !== undefined && value != null)
if ($(this).val() === value) $(this).attr("checked", true);
else $(this).attr("checked", false);
} else if ($(this).attr("type") === 'date') {
value = this.value;
localStorage.setItem(col_id, value);
var splitted = col_id.split('-');
var min_val = undefined;
var max_val = undefined;
if (splitted[splitted.length - 1] === "min") {
min_val = this.value;
splitted.length = splitted.length - 1;
col_id = splitted.join("-");
max_val = $("#" + col_id + '-max').val()
} else {
value = localStorage.getItem(col_id);
if (value !== undefined && value !== null)
$(this).val(value);
max_val = this.value;
splitted.length = splitted.length - 1;
col_id = splitted.join("-");
min_val = $("#" + col_id + '-min').val()
}
if (min_val === undefined && max_val !== undefined)
min_val = max_val;
if (max_val === undefined && min_val !== undefined)
max_val = min_val;
if (max_val !== undefined && min_val !== undefined && min_val !== "" && max_val !== "" && min_val !== null && max_val !== null)
o${tableid}
.column($(this).data('index'))
.search(min_val + '-yadcf_delim-' + max_val, true)
} else {
col_id = this.id;
value = this.value;
if (value === undefined || value === null) {
value = "";
}
console.log(col_id, $(this).attr('id'), value);
})
console.log(col_id, $(this).attr('id'), value, $(this).data('index'));
localStorage.setItem(col_id, value);
o${tableid}
.column($(this).data('index'))
.search(value);
}
});
o${tableid}.draw();
}
$(".${tableid}-control-filter").on('click', function (e) {
console.log("Write Data Click");
var typ = $(this).attr("type");
if (typ === 'radio') {
filter_table()
}
});
$(".${tableid}-control-filter").on('change', function (e) {
var typ = $(this).prop("nodeName").toLowerCase();
if (typ === "select") {
filter_table()
}
var typ = $(this).attr("type").toLowerCase();
if (typ === "date") {
filter_table()
}
});
${structure:btnscripts}
console.log("Read Data");
$(".${tableid}-control-filter").each(function (e) {
var col_id = $(this).attr("id")
var value;
if ($(this).attr("type") === 'radio') {
col_id = $(this).attr('id').split("-");
col_id.length = 2;
col_id = col_id.join("-");
value = localStorage.getItem(col_id);
if (value !== undefined && value != null)
if ($(this).val() === value) $(this).attr("checked", true);
else $(this).attr("checked", false);
} else {
value = localStorage.getItem(col_id);
if (value !== undefined && value !== null)
$(this).val(value);
}
)
;
console.log(col_id, $(this).attr('id'), value);
});
});
</script>
</div>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!