如何用数据表jquery进行分页

时间:2016-06-28 05:35:52

标签: jquery datatables

      $.ajax({
  type: 'GET',
  url: 'http://staging.me/api/v1/orders',
  dataType: 'json',
  success: function(jsonData) {
      $('#order-table').DataTable({
        "bPaginate": true,
        "bSort": false,
        "bInfo": false,
        "iTotalRecords": jsonData.meta.pagination.total,
        "aaData": jsonData.data,
        "aoColumns": [
            { "mDataProp": "payment_ref_id" },
            { "mDataProp": "purchased_at" },
            {"mDataProp": "order_history.data[0].internal_status_code",
                   "render": function ( data, type, row, meta ) {
                        if(row.order_history.data[0].internal_status_code==="ORD_INITIATED") {
                            return "Order Initiated"
                        } else if(row.order_history.data[0].internal_status_code==="PAYMENT_INITIATED") {
                            return "Payment Intiated"; //Show the latest Order status
                       } else {
                           return row.order_history.data[0].internal_status_code;
                       }
                 }
            },
            { "mDataProp": "payment_details.data[0].name" },
            {"mDataProp": "id",
                        "render": function( data, type, row, meta ) {
                           return '<button type="button" class="btn btn-warning btn-sm" id="'+data+'">View</button>';
                        }
            }
        ]
    });

我得到的json数据与meta

在以下链接中

https://jsfiddle.net/avg2pa89/

请有人帮助我如何使用数据表调用meta中的下一个和上一个链接。

0 个答案:

没有答案