ordering the first column in Descending order

ordering the first column in Descending order

markmatthewsmarkmatthews Posts: 1Questions: 1Answers: 0
edited December 2022 in Free community support

****CSS code****:

<script type="text/javascript">
    $(document).ready( function () {
        $('#myTableD').DataTable();( {
            order: [[ 0, 'desc' ]],
        } );} );
</script>

****PHP code****

if ($result) {
    echo '<br/><br/><br/><br/>'; 
    echo '<h3><strong>(Click on Name to add to Course'  . ' ' . $holds . $holdtype . ')</strong></h3>'; 
        echo '<table id="myTableD" class="stripe hover row-border" border="1" cellspacing="0" cellpadding="3"><thead>
    <tr>
    <th>Id</th>
    <th>First Name</th>
    <th>Last name</th>
    <th>email</th>
    </tr></thead><tbody>';

****Table Result****:

Id  First Name  Last name   email
1   Sandra        Andersen         s@health.sdu.dk
2   Helle         Bovin                h@health.sdu.dk
3   Stine         Hanghøi          s@rsyd.dk

Description of problem:

I have tried and tried but I am unable to get the first column to show in descending order.
What I am doing wrong please?

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Can you link to a test case showing the issue please? If that isn't possible, use the debugger to give me a trace please - click the Upload button and then let me know what the debug code is.

    Allan

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    Guessing you are loading the table data after initializing Datatables. See this FAQ.

    Kevin

Sign In or Register to comment.