Q: 要在dataTAble一格內帶進data中的兩個變數該如何做?

<script type="text/javascript">
        $(document).ready(function () {
            $('#datatable-responsive').DataTable({
                "columns": [
                    {"data": "fname"},
                    {"data": "phoneno"},
                    {"data": "email"},
                    {"data": "idno"},
                    {"data": "idno"},
                    {"data": "status"}

                ], 

                "processing": true,
                "fixedHeader": true,
                "serverSide": true,
                "ajax": {
                    url: '../lib/request/viewrequests.php',
                    type: 'POST'
                }
            });
        });
    </script>

A: 將data設為null,使用render function,從row參數中取得整列的資料

Use columns.render option to define a rendering function.

For example:

"columns": [
    {"data": "fname"},
    {"data": "phoneno"},
    {"data": "email"},
    {"data": "idno"},
    {"data": "status"},
    {
       "data": null,
       "render": function(data, type, full, meta){
          return full["idno"] + ", " + full["status"];
       }
    }
], 

--

轉自 https://stackoverflow.com/questions/38293899/how-to-pass-two-columns-from-database-to-one-datatable-cell

arrow
arrow
    全站熱搜

    dizzy03 發表在 痞客邦 留言(0) 人氣()