Reputation: 2283
I am Using Data table jQuery plugin for filtring my data.
this is my sql query
$sql = "SELECT * FROM project_task where emp_id ='$empid' AND task_type ='random' ORDER BY task_id DESC";
code of table is
<table id="example" class="table table-hover" style="width:100%">
<thead>
<tr style="background: #064769;color: #FFF;">
<th>id</th>
<th>Task</th>
<th > Description </th>
<th> Hours </th>
<th> Date </th>
<th> Rating </th>
</tr>
</thead>
<tbody id="tbody">
<tr>
<td> <?php echo $row["task_id"] ?></td>
<td> <?php echo $row["task"] ?></td>
<td> <?php echo $row["description"]; ?> </td>
<td> <?php echo $row["hours"]; ?> </td>
<td> <?php echo $row["submit_date"];?></td>
<td> <?php echo $row["submit_date"];?></td>
</tr>
</tbody>
</table>
as per I am Using DESC in sql query. task has been shown in DESC order but not when i remove data table plugin it is working fine. I think there is filter which is working on page load. I was using cdn now i installed it into local i am finding that there is any function which is sorting it but i have not pro in JS if you know how to solve it please tell me.
I am attaching screen shot also: which is showing tasks are sorted automatically ASC order.
this is my jQuery function for data table:
$(document).ready(function() {
$('#example').DataTable();
});
Upvotes: 1
Views: 400
Reputation: 62
in your jquery code you have pass arguments like:
$(document).ready(function() {
$('#example').DataTable( {
"paging": true,
"ordering": false,
"info": true
} );
});
you can also see documentation for the more clarity .
Upvotes: 1