In package.json, I added the following-
"datatables.net": "^2.1.1",
"datatables.net-bs4": "^3.2.2",
"datatables.net-responsive": "^2.2.3",
"datatables.net-responsive-bs4": "^2.2.3",
"datatables.net-select": "^1.2.7"
then in bundles.js - for "output": "view-resources/Views/_Bundles/frontend-libs.min.js", added the following
"wwwroot/lib/datatables.net/js/jquery.dataTables.js",
"wwwroot/lib/datatables.net-bs4/js/dataTables.bootstrap4.js",
"wwwroot/lib/datatables.net-select/js/dataTables.select.js",
"wwwroot/lib/datatables.net-responsive/js/dataTables.responsive.js",
"wwwroot/lib/datatables.net-responsive-bs4/js/responsive.bootstrap4.js"
Executed: npm run create-bundles
When I try to use DataTable like- var dataTable = _$table.DataTable({ .. .. });
It gives error on browser that _$table.DataTable is not a function
Is there anything I am missing?
4 Answer(s)
-
0
Hi,
When you add packages to pacakge.json, they are installed under node_modules folder. So, you should use "node_modules/" instead of "wwwroot/lib/" for the script files in bundles.json.
For example;
"wwwroot/lib/datatables.net/js/jquery.dataTables.js"
becomes"node_modules/datatables.net/js/jquery.dataTables.js"
Don't forget to install npm packages again using "yarn" command before running "npm run create-bundles" command.
-
0
Thanks @ismcagdas
I read somewhere on stackoverflow that aspnetzero customized DataTables to support consumption of AppServices. I need access to those functions as well so do I need to include anything additional in package.json?
-
0
Hi,
Sorry for my late reply. I think this is what you are looking for https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/wwwroot/Common/Scripts/Datatables/datatables.ajax.js
Same file must exist in your solution if you are using ASP.NET Core & jQuery version of AspNet Zero.
-
0
This issue is closed because it has not had recent activity for a long time.