I'm trying to get the jquery datatable export buttons to display on an cshtml view in my MVC application.
The error is
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'i18n' Unhandled exception at line 13, column 363 in http://localhost:52104/Scripts/buttons.html5.min.js which points to the buttons.html5.min.js script text:function(a){return a.i18n("buttons.excel","Excel")}
I created a proof of concept view just to see if the buttons would show up and work. The scripts are included in the BundleConfig.cs file
bundles.Add(new ScriptBundle("~/bundles/misc_scripts").Include(
"~/Scripts/autosize.js",
"~/Scripts/jquery.dataTables.min.js",
"~/Scripts/dataTables.bootstrap.js",
"~/Scripts/dataTables.responsive.min.js",
"~/Scripts/dataTables.buttons.min.js",
"~/Scripts/buttons.html5.min.js",
"~/Scripts/buttons.print.min.js",
"~/Scripts/jszip.min.js",
"~/Scripts/pdfmake.min.js",
"~/Scripts/vfs_fonts.js",
"~/Scripts/select2.min.js",
"~/Scripts/App/Shared.js"
<table id="example" class="display nowrap" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$3,120</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Director</td>
<td>Edinburgh</td>
<td>63</td>
<td>2011/07/25</td>
<td>$5,300</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$4,800</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function () {
var table = $('#example').DataTable({
dom: 'Bfrtip',
buttons: ['excelHtml5']
});
});
</script>
Thanks for your help
User contributions licensed under CC BY-SA 3.0