dongxie3352 2016-07-02 09:17
浏览 36
已采纳

由Desc oder订购的JQuery数据表

I'm using JQuery datatable for my table however I want the last entry to appear first as in the table to appear in a descending order. Tried changing the PHP MYSQL select statement but not working. I thought, could this be the code to arrange as to my needs? I f so, any one lead me how to oder the same? Thank you...

<link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css">
    <script type="text/javascript" language="javascript" src="js/jquery.js"></script>
    <script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
    <script type="text/javascript" language="javascript" >
        $(document).ready(function() {
            var dataTable = $('#employee-grid').DataTable( {
                "processing": true,
                "serverSide": true,
                "ajax":{
                    url :"employee-grid-data.php", // json datasource
                    type: "post",  // method  , by default get

                    error: function(){  // error handling
                        $(".employee-grid-error").html("");
                        $("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">No data found in the server</th></tr></tbody>');
                        $("#employee-grid_processing").css("display","none");

                    }
                }
            } );
        } );

    </script>
  • 写回答

3条回答 默认 最新

  • dongpanshi2839 2016-07-02 09:26
    关注

    You need to specify the default order column, like this:

    var dataTable = $('#employee-grid').DataTable( {
            "order": [[ 1, "desc" ]],
     "processing": true,
                    "serverSide": true,
            "ajax":{
                url :"employee-grid-data.php", // json datasource
                type: "post",  // method  , by default get
    
                error: function(){  // error handling
                    $(".employee-grid-error").html("");
                    $("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">No data found in the server</th></tr></tbody>');
                    $("#employee-grid_processing").css("display","none");
    
                }
            }
        } );
    

    Check the Datatables docs for more information: https://datatables.net/examples/basic_init/table_sorting.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测