Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello

I am having problems trying to get my data table to work in vb.net mvc.
Ive been able to do this before but in C#. The issue seems to be with the javascript.

I have got copies of the script files in the source code but i have also tried links to the js file from the internet.

Can someone please help ?

What I have tried:

@ModelType List(Of Call_Log_Template.Customer)
@Code
    ViewData("Title") = "Index"
End Code


<!-- Navbar -->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">


    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-12">
                    <div class="card">

                        <!-- /.card-header -->

                        <div class="card">
                            <!-- /.card-header -->
                            <div class="card-body">
                                <table id="example1" class="table table-bordered table-hover">
                                    <tr>

                                        <th>
                                            Company
                                        </th>
                                        <th>
                                            Phone
                                        </th>
                                        <th>
                                            Layouts
                                        </th>
                                        <th>
                                            Last Lite
                                        </th>
                                        <th>
                                            Check In
                                        </th>
                                        <th>
                                            C30D
                                        </th>
                                        <th>
                                            C12M
                                        </th>
                                        <th>
                                            T12M
                                        </th>

                                    </tr>

                                    @For Each item In Model
                                        @<tr onclick="location.href = '@Url.Action("GetCustomer", "Customer", New With {.id = item.guid_Company})'">

                                            <td>
                                                @item.CompanyNameWithAlsoKnown
                                            </td>
                                            <td>
                                                @item.PhoneNumber
                                            </td>
                                            <td>
                                                @item.Layouts
                                            </td>

                                            <td>
                                                @item.LastLiteUpdate.ToShortDateString()
                                            </td>
                                            <td>
                                                @item.LastCheckIn.ToShortDateString()
                                            </td>

                                            <td>
                                                @item.Calls30D
                                            </td>
                                            <td>
                                                @item.Calls12M
                                            </td>
                                            <td>
                                                @item.Tickets12M
                                            </td>

                                        </tr>
                                    Next

                                </table>

                            </div>

                        </div>

                    </div>

                </div>

            </div>
        </div>

    </section>

</div>





@section scripts
    <script src="https://ajax.microsoft.com/ajax/jquery/jquery-1.10.2.js" type="text/javascript"></script>
    <script src="https://cdn.datatables.net/1.10.18/js/jquery.dataTables.min.js"></script>

    <script src="~/bower_components/jquery/dist/jquery.min.js"></script>
    <script src="~/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="~/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="~/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>

    <script type="text/javascript">
        $(function () {

            $('#example1').DataTable({

                'paging': true,
                'lengthChange': true,
                'searching': true,
                'ordering': true,
                'info': true,
                'autoWidth': true,
            })
        })



    </script>
End Section
Posted
Comments
Richard Deeming 8-Jun-22 5:20am    
Aside from the fact that you've included two references to the jQuery and DataTables libraries, you haven't actually told us what the problem is.

Remove the duplicate script tags, and then check your browser's developer console for errors. If you need help to fix them, then edit your question and provide the full details of the errors you're getting.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900