Export not working on a specific table
Export not working on a specific table
itchyo
Posts: 2Questions: 1Answers: 1
Hi,
I'm developing on the Spring MVC framework and I'm using JSP to represent my web pages.
I've got multiple tables on my app which takes displays data from an oracle database however there is one table where the export does not work.
I've attached the code below - I can't find any problems with it however when I click the export button there is no response/action.
//Builds table html
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<div class ="row">
<table class = "table" id= "auditTable" width="100%">
<thead>
<tr>
<th>User</th>
<th>Timestamp</th>
<th>Action</th>
<th>Url</th>
<th>HTTP Action</th>
<th>Description</th>
<th>INC Number</th>
</tr>
</thead>
<tfoot>
<tr>
<th>User</th>
<th>Timestamp</th>
<th>Action</th>
<th>Url</th>
<th>HTTP Action</th>
<th>Description</th>
<th>INC Number</th>
</tr>
</tfoot>
<tbody id ="auditRecords">
<c:forEach items="${auditTable}" var="listItem">
<tr data-filter =${listItem.date.getTime()}>
<td>${listItem.username}</td>
<td data-order = ${listItem.date.getTime()} ><fmt:formatDate type="both" dateStyle="short" timeStyle="short" value="${listItem.date}"/></td>
<td>${listItem.action}</td>
<td>${listItem.url}</td>
<td>${listItem.http_action}</td>
<td>${listItem.description}</td>
<td>${listItem.incident}</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<div class="row">
<button class="btn btn-large btn-primary col-md-1 pull-right" onclick="ClearSearch()" type="button" input="" value="clearSearch"> Clear Filter </button>
</div>
//JS
<script>
var auditTable;
$(document).ready(function() {
$('#auditTable tfoot th').each( function (){
var title = $('#auditTable thead th').eq($(this).index()).text();
$(this).html( '<input type="text" placeholder="Search '+title+'" />' );
});
// DataTable
auditTable = $("#auditTable").DataTable({
"dom":
"<'row'<'col-sm-6'B>>"+
"<'row'<'col-sm-6'l>>"+
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"sPaginationType": "full_numbers",
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
"width" :"100%",
"striped":true,
"buttons":[
{
extend:'colvis',
columns: ':gt(0)',
text:'Hide/Show'
},
{
extend:'csvHtml5',
text:'Export',
}],
responsive: true,
stateSave: true
});
// Apply the search
auditTable.columns().eq(0).each(function(colIdx) {
$('input', auditTable.column(colIdx).footer()).on('keyup change', function() {
auditTable
.column(colIdx)
.search(this.value)
.draw();
});
$('input', auditTable.column(colIdx).footer()).on('click', function(e) {
e.stopPropagation();
});
});
});
function ClearSearch(){
auditTable.search( '' )
.columns().search( '' )
.draw();
}
</script>
Thanks!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Found the issue...
turns out when I was defining my pages using apache tiles I did not give this page a title, which (I think) caused the error because the API did not know what to name the exported file.
Thanks for posting back. Good to hear you've got it sorted out.
Allan