Using dataTables and Editor vai yarn add (npm) and experiencing issues
Using dataTables and Editor vai yarn add (npm) and experiencing issues
autumndev
Posts: 8Questions: 3Answers: 0
Hi All,
I am recieving the following errors when trying to load the editor. In a bootstrap js file i have:
/**
* DataTables
*/
require( 'datatables.net' )(window, window.$);
require( 'datatables.net-editor' )(window, window.$);
Then in my view file code:
<script type="text/javascript">
var editor = new $.fn.dataTable.Editor( {
ajax: '/api/datatables/pricing',
table: '#pricingTable',
fields: [
{ label: 'First name', name: 'first_name' },
{ label: 'Last name', name: 'last_name' },
// etc
]
} );
$('#pricingTable').DataTable( {
ajax: '/api/datatables/pricing',
dom: 'Bfrtip',
fixedColumns: true,
scrollX: true,
scrollCollapse: true,
fixedColumns: {
leftColumns: 7
},
select: true,
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor }
]
} );
</script>
However I am getting the following errors that I cannot seem to figure out:
TypeError: this is undefined[Learn More] app-8391eece1d.js line 127 > eval:132:3
DataTable https://dev.localhost/build/js/app-8391eece1d.js line 127 > eval:132
<anonymous> https://dev.localhost/build/js/app-8391eece1d.js line 883 > eval:20
<anonymous> https://dev.localhost/build/js/app-8391eece1d.js:883
__webpack_require__ https://dev.localhost/build/js/app-8391eece1d.js:20
<anonymous> https://dev.localhost/build/js/app-8391eece1d.js line 2413 > eval:11
<anonymous> https://dev.localhost/build/js/app-8391eece1d.js:2413
__webpack_require__ https://dev.localhost/build/js/app-8391eece1d.js:20
<anonymous> https://dev.localhost/build/js/app-8391eece1d.js:64
<anonymous> https://dev.localhost/build/js/app-8391eece1d.js:1
TypeError: $.fn.dataTable.Editor is not a constructor[Learn More] index:305:14
<anonymous> https://dev.localhost/datatables/index:305
Any help is hugely appreciated.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
Are you able to give me a link to your page so I can take a look please? I don't recall having seen that error before, so I'm not certain what is causing it.
Allan
Hi Allan,
thanks for getting back to me. I believe i figured it out, currently im using the CDN; however when using the npm packages i realised i was a fool - didnt read the doc's properly and didn't run the editor install.js command...
My Bad.