0

I donwload jQuery Datatable and the files I put it in my wwwroot folder. This is the structure of wwwroot folder:

 -wwwroot
             -css
             -DataTable 
               -DataTables-1.10.21
                  -css
                  -images
                  -js
               -datatables.css
               -datatables.js
             -IMG
             -js
             -lib

In my _Layout.cshtml I inserted :

  <link rel="stylesheet" href="~/DataTable/datatables.css" />
    <script type="text/javascript" charset="utf8" src="~/DataTable/datatables.js"></script>  

to use jQuery Datatable.

But I can't use it in my view page. This is what I try to do in my view page :

 *<table class="table table-hover" id="tblmissioni">

        <thead>
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.Nome)
                </th>
                .....
             </tr>
        </thead>
<script>
        $(document).ready(function () {
            $("#tblmissioni").DataTable(
                {
                    "ajax": {
                        "url": "/Missioni/Missioni",
                        "type": "GET",
                        "datatype": "json"
                    },
                    "columns": [
                        { "data": "asdasd" },
                        { "data": "asdasd" },
                        { "data": "asdasd" },
                        { "data": "asdasd" },
                        { "data": "asdasd" },
                        { "data": "asdasd" },
                        { "data": "asdasd" },
                        ---I have 45 colums----
                    ]
                });
        }
    </script>*

Is it correct to do like this or not? I don't know if my <link> and <script> are correct in _Layout.cshtml

Errors

Any suggestions how to fix this?

Thanks in advance!

kvacka
  • 27
  • 1
  • 10
  • How specifically does this fail? Check the browser's development tools. Are there any errors on the browser's development console? – David Jul 08 '20 at 13:39
  • Here are the errors : https://i.stack.imgur.com/ttwe1.png – kvacka Jul 08 '20 at 13:42
  • You forgot to include jQuery in your code. DataTables depends on that library. It also looks like you have a syntax error to address. (You never close the call to `.ready()`) – David Jul 08 '20 at 13:47

0 Answers0