Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Installing DataTable in public project #7771


User avatar
0
huntethan89 created

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)
  • User Avatar
    0
    ismcagdas created
    Support Team

    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.

  • User Avatar
    0
    huntethan89 created

    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?

  • User Avatar
    0
    ismcagdas created
    Support Team

    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.

  • User Avatar
    0
    ismcagdas created
    Support Team

    This issue is closed because it has not had recent activity for a long time.