2015-09-02 20 views
-1

我已經使用這個datatabel示例http://www.paulzepernick.com/ci-zepernick/。 但我不知道要添加編輯和刪除列。如何使用codeignitor添加編輯,刪除數據標籤中的列

$(function() { 
//wait till the page is fully loaded before loading table 
//dataTableSearch() is optional. It is a jQuery plugin that looks for input fields in the thead to bind to the table searching 
$("#sampleOrderTable").dataTable({ 
    processing: true, 
serverSide: true, 
    ajax: { 
"url": JS_BASE_URL + "/DatatableControl/dataTable", 
"type": "POST" 
}, 
columns: [ 
{ data: "o.serial_order_id" }, 
{ data: "o.date" }, 
{ data: "c.fname" }, 
{ data: "c.lname" }, 
{ data: "c.email" }, 
{ data: "o.payment_type" } 
] 
}).dataTableSearch(500); 
}); 

這是我的jquery函數。

+0

你想使用jQuery或笨? –

+0

使用codeignitor – archana

回答

0

我使用這樣的選項。將這個代碼後列括號:

columns: [ 
{data: 'o.serialid'}, 
... 
{data: 'o.paymenttime'}, 
], 

"columnDefs": [ { 
      "render": function (data, type, row) { 
       return '<a class="uk-button uk-button-primary" href="/admin/products/edit/'+data +'">Edit</a> <a class="products__delete-button uk-button" data-id='+data+' href="/admin/products/delete/'+data +'">Delete</a>'; 
      }, 
     "targets": 0, 
     } ] 
    }).dataTableSearch(500); 

而這裏的,我使用的內部控制器返回數據的代碼:

/** 
* get json for index, datatables specific situation 
* 
* @return array json 
*/ 
public function get_json() 
{ 
    $this->load->library('Datatable', array('model' => 'product_dt_model','rowIdCol'=> 'nrart')); 
    $json = $this -> datatable -> datatableJson(); 
    $this -> output -> set_header("Pragma: no-cache"); 
    $this -> output -> set_header("Cache-Control: no-store, no-cache"); 
    $this -> output -> set_content_type('application/json') -> set_output(json_encode($json)); 
} 
+0

感謝它的工作,但它顯示在第一列編輯和刪除我的order_id的地方我希望它顯示在最後。 order_id |訂單日期| fname | lname |電子郵件| payment_type 編輯| 2015年9月1日|阿奇納| khairwar | [email protected] | cod 刪除 – archana

+0

嘗試更改目標選項 - 它指定它的目標列,https://datatables.net/reference/option/columnDefs – cssBlaster21895

+0

感謝它的工作 – archana

相關問題