Syntax error, unrecognized expression: 10/20/21 while exporting excel or pdf
Syntax error, unrecognized expression: 10/20/21 while exporting excel or pdf
Hi allan,
can you tell me the exact reason behind this error..
below is my code...
<!DOCTYPE html>
<html>
<head>
<title>Datatable with textbox in TD</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.5.1/css/buttons.dataTables.min.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var buttonCommon = {
exportOptions: {
format: {
body: function ( data, row, column, node ) {
return $(data).is("input") ?
$(data).val():
data;
}
}
}
};
$("#example").dataTable( {
dom: 'Bfrtip',
"buttons": [
$.extend( true, {}, buttonCommon, {
extend: 'excelHtml5'
} ),
$.extend( true, {}, buttonCommon, {extend:'pdf'})
]} );
});
</script>
</head>
<body>
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Start Date</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>10/20/21</td>
<td><input type="text" name="txt" value="66"></td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>18/20/21</td>
<td><input type="text" name="txt1" value="63"></td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>20/20/21</td>
<td><input type="text" name="txt2" value="06"></td>
</tr>
</tbody>
</table>
</body>
</html>
What i exactly need is how to print value of text box when exported. This works perfectly when there is no date format containing ' / '. Please help me out.
Thanks & Regards,
S Pankaj Sharma
Answers
Thanks for your question. As noted in the forum rules, please post a link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Allan