2016-08-18 10 views
0

この実装で何が問題なのか分かりません。私のデータは行/列の座標に基づいて作成されたセルを計画するので、私のデータは "空である"ことに注意してください。だから私はダミーの配列を渡し、render()コールバックの内容を返します。Datatables deferRender延期しない

コンソールログには、createdCell()が100 * 100回呼び出されます...生成されたHTMLも同意します。

var size = 100 
 
var zeroes = new Uint8Array(size) 
 
var data = _.range(size).map(function() { 
 
    return zeroes 
 
}) 
 
var cells = 0 
 
var rows = 0 
 
var config = { 
 
    autoWidth: false, 
 
    paging: false, // Disable Paging         
 
    ordering: true, // Sortable columns         
 
    info: false, // Disable 'showing x of x entries'     
 
    data: data, 
 
    deferRender: true, 
 
    processing: true, 
 
    createdRow: function(cell, data, dataIndex) { 
 
    rows += 1 
 
    }, 
 
    columnDefs: [{ 
 
    targets: _.range(size), 
 
    title: 'Title', 
 
    render: function(data, type, row, meta) { 
 
     return meta.col * meta.row 
 
    }, 
 
    createdCell: function(cell, cellData, rowData, rowIndex, colIndex) { 
 
     cells += 1 
 
    }, 
 
    }], 
 
} 
 
var dataTable = $('#dashboard-table').DataTable(config) 
 
console.log("Rows: " + rows) 
 
console.log("Cells: " + cells)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/js/jquery.dataTables.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script> 
 

 
<link href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.12/css/jquery.dataTables.min.css" rel="stylesheet"/> 
 

 
<table className="table table-compressed" id="dashboard-table"> 
 
</table>

ここでフィドルも同様です:

https://jsfiddle.net/rrauenza/x5nj7qgt/

これは、細胞の作成を延期されていないのはなぜ?

答えて

1

ああ、私は何が起こっているかを見ていると思います。 deferRenderは、config内のpaging=trueが動作し、追加のページレンダリングを延期する場合にのみ機能します。

Datatables Scrollerプラグインは、私が期待しているものに近いかもしれません。

関連する問題