Skip to content
Snippets Groups Projects
Commit cbe506aa authored by Piotr Gawron's avatar Piotr Gawron
Browse files

clicking on search fiekd doesn't change order by

parent 47ca62ef
No related branches found
No related tags found
1 merge request!34Performance of subject list
......@@ -95,14 +95,14 @@ def get_subjects_filtered(subjects, filters):
result = result.filter(screening_number__contains=value)
else:
print row
# elif order_column == "default_location":
# result = subjects.order_by(order_direction + 'default_location')
# elif order_column == "dead":
# result = subjects.order_by(order_direction + 'dead')
# elif order_column == "resigned":
# result = subjects.order_by(order_direction + 'resigned')
# elif order_column == "postponed":
# result = subjects.order_by(order_direction + 'postponed')
# elif order_column == "default_location":
# result = subjects.order_by(order_direction + 'default_location')
# elif order_column == "dead":
# result = subjects.order_by(order_direction + 'dead')
# elif order_column == "resigned":
# result = subjects.order_by(order_direction + 'resigned')
# elif order_column == "postponed":
# result = subjects.order_by(order_direction + 'postponed')
return result
......@@ -154,6 +154,13 @@ def subjects(request, type):
})
def get_yes_no(val):
if val:
return "YES"
else:
return "NO"
def serialize_subject(subject):
location = ""
if subject.default_location is not None:
......@@ -165,9 +172,9 @@ def serialize_subject(subject):
"nd_number": subject.nd_number,
"screening_number": subject.screening_number,
"default_location": location,
"dead": subject.dead,
"resigned": subject.resigned,
"postponed": subject.postponed,
"dead": get_yes_no(subject.dead),
"resigned": get_yes_no(subject.resigned),
"postponed": get_yes_no(subject.postponed),
}
return result
......
......@@ -28,32 +28,41 @@
<div class="box-body">
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<th>ND</th>
<th>Screening</th>
<th>First name
</th>
<th>Last name</th>
<th>Default location</th>
<th>Deceased</th>
<th>Resigned</th>
<th>Postponed</th>
<th>Edit</th>
</tr>
</thead>
<tfoot style="display: table-header-group;">
<tr>
<th>
<div name="string_filter">ND</div>
ND
</th>
<th>
<div name="string_filter">Screening number</div>
Screening
</th>
<th>
<div name="string_filter">Name</div>
First name
</th>
<th>
<div name="string_filter">Surname</div>
Last name
</th>
<th>Default location</th>
<th>Deceased</th>
<th>
<div name="yes_no_filter">---</div>
</th>
<th>Resigned</th>
<th>Postponed</th>
<th>Edit</th>
</tr>
</thead>
</tfoot>
<tbody>
</tbody>
......@@ -68,11 +77,16 @@
<script src="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.min.js' %}"></script>
<script>
$('#table thead div[name="string_filter"]').each(function () {
$('#table tfoot div[name="string_filter"]').each(function () {
var title = $(this).text();
$(this).html('<input type="text" placeholder="Search ' + title + '" />');
});
$('#table tfoot div[name="yes_no_filter"]').each(function () {
var title = $(this).text();
$(this).html('<select ><option value selected="selected">----------</option><option value="true">YES</option><option value="false">NO</option></select>');
});
$(function () {
var table = $('#table').DataTable({
serverSide: true,
......@@ -93,7 +107,7 @@
table.columns().every(function () {
var that = this;
$('input', this.header()).on('keyup change', function () {
$('input', this.footer()).on('keyup change', function () {
if (that.search() !== this.value) {
that
.search(this.value)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment