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

edit button exists in subject lists

parent 8ab77aea
No related branches found
No related tags found
1 merge request!34Performance of subject list
......@@ -191,6 +191,7 @@ def serialize_subject(subject):
"dead": get_yes_no(subject.dead),
"resigned": get_yes_no(subject.resigned),
"postponed": get_yes_no(subject.postponed),
"id": subject.id,
}
return result
......
......@@ -98,7 +98,7 @@
obj.html('<select ><option value selected="selected">----------</option></select>');
$.get("{% url 'web.api.locations' %}", function (data) {
$.each(data.locations, function (index, location) {
$('select', obj).append( '<option value="' + location.id + '">' + location.name + '</option>');
$('select', obj).append('<option value="' + location.id + '">' + location.name + '</option>');
});
});
});
......@@ -107,6 +107,7 @@
var table = $('#table').DataTable({
serverSide: true,
processing: true,
defaultContent: "<button>Click!</button>",
ajax: "{% url 'web.api.subjects' list_type %}",
columns: [
{"data": "nd_number"},
......@@ -116,9 +117,22 @@
{"data": "default_location"},
{"data": "dead"},
{"data": "resigned"},
{"data": "postponed"}
]
{"data": "postponed"},
{"data": null},
],
columnDefs: [{
"targets": 8,
"data": "id",
"defaultContent": '<a href="#" type="button" class="btn btn-block btn-default">Edit</a>'
}]
});
$('#table tbody').on('click', 'a', function () {
var data = table.row($(this).parents('tr')).data();
var url = "{% url 'web.views.subject_edit' 12345 %}".replace(/12345/, data.id.toString());
window.location.href = url;
});
// Apply the search
table.columns().every(function () {
var that = this;
......@@ -138,7 +152,7 @@
}
});
});
$('#table_filter').css("display","none");
$('#table_filter').css("display", "none");
});
</script>
......
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