dataTable有增加child row的寫法

參照: https://datatables.net/examples/api/row_details.html

child row預設是不顯示的,當點選"+"符號時才會展開。

 

現在要預設顯示

解法:

 

$("#example").DataTable().rows().every( function () {
    var tr = $(this.node());
    this.child(format(tr.data('child-value'))).show();
    tr.addClass('shown');
});

 

 

但是這個要在datatable資料產生後呼叫才有用,當資料為ajax取得時就不能加在document.ready中。

所以承上篇

 

[dataTable] 如何在Datatable ajax結束呼叫function: fnInitComplete, run-a-function-after-ajax-request-finished

必須要加在fnInitComplete function中才行!

 

 

--

https://datatables.net/forums/discussion/35202/display-child-rows-always-open

 

--

arrow
arrow
    全站熱搜

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