Descending order

Descending order

jbcom41@outlook.comjbcom41@outlook.com Posts: 4Questions: 3Answers: 0

Hi, really sorry if I am not following protocol, total newbie at this stuff.... my issue is that the data being returned is not in descending order - just wondering if someone can point me in the correct direction?

Big thanks in advance :)

John

@model IEnumerable<CHALogins.Models.LoginUsers>

@{
ViewData["Title"] = "Home Page";
}

<html>
<head>
<meta name="viewport" content="width=device-width" />
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<link ref="//cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css" rel="stylesheet" />
<script src="//cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
<link href="//cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css" rel="stylesheet" />

</head>

<body>
<div class="alert alert-info">
<strong>Showing 1 to 10 of 2,000 entries of most recent logins</strong>
</div>
<h1>Log Details</h1>
<br />
<div>

    <table id="TEP" class="display">
        <thead>
            <tr>
                <th>Id</th>
                <th>Event</th>
                <th>Date</th>
                <th>Time</th>
                <th>Device</th>
                <th>User</th>
                <th>IP</th>
                <th>SN</th>
                <th>Model</th>
            </tr>
        </thead>
        <tbody>

    </table>
</div>




@section Scripts{
    <script src="//cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
    <script>
        $(document).ready(function () {
        $('#TEP').DataTable(
                {
                    ajax: {
                    url: "LoginUsers/GetEmployeeList",
                        type: "POST",

                    },

                    processing: true,
                    serverSide: true,
                    filter: true,
                    order: [0, 'desc'],


                    columns: [
                        { data: "id", name: "Id" },
                        { data: "event", name: "Event" },
                        { data: "date", name: "Date" },
                        { data: "time", name: "Time" },
                        { data: "device", name: "Device" },
                        { data: "user", name: "User" },
                        { data: "ip", name: "IP" },
                        { data: "sn", name: "SN" },
                        { data: "model", name: "Model" },
                    ]

                }
            );
        });
    </script>

}

</body>

</html>

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    Your tbody has no closing tag.

  • kthorngrenkthorngren Posts: 21,213Questions: 26Answers: 4,928

    You have enabled server side processing with serverSide: true,. Server side processing expects the server script to perform all sorting, paging and searching operations.

    Are you using a Datatables supplied server side processing script?

    Do you need server side processing enabled? See the processing modes doc.

    Kevin

Sign In or Register to comment.