、それが動作するはずです:ここでは
を、JSで動作するはずのソリューションです上のように:
{ "draw": 2, "recordsTotal": 3, "recordsFiltered": 3, "data": [{ "type": "normal", "description": "Zenaida", "name": "Frank", "age": "Software Engineer", "location": "New York" }, { "type": "detail", "detail": "first detail" }, { "type": "detail", "detail": "second detail" }, { "type": "detail", "detail": "third detail" }, { "type": "normal", "description": "zerrz", "name": "paul", "age": "Software breaker", "location": "Lodon" }, { "type": "detail", "detail": "third detail" }, { "type": "normal", "description": "Zenaida", "name": "Frank", "age": "Software Engineer", "location": "New York" }, { "type": "detail", "detail": "second detail" }, { "type": "detail", "detail": "third detail" }] }
$('#example').dataTable({ "processing": true, "serverSide": true, "ajax": "YourAjaxSource", "columns": [ //You have to manually bind your column since the first value is not to be displayed { "data": "details" }, { "data": "description" }, { "data": "name" }, { "data": "age" }, { "data": "location" } ], "fnRowCallback": function(nRow, aData, iDisplayIndex, iDisplayIndexFull) { switch (aData[0]) { //first value indicates if its a detail row or a normal row case 'normal': // if its a normal row, just display the cells without the first detail one $(nRow).find('td')[0].style.display = 'none'; break; case 'detail': //else display none of the cells except the detail one with take up 5 cells $(nRow).find('td')[1].style.display = 'none'; $(nRow).find('td')[2].style.display = 'none'; $(nRow).find('td')[3].style.display = 'none'; $(nRow).find('td')[4].style.display = 'none'; $(nRow).find('td')[0].colSpan = '5'; //Your number of column break; } } });
それが動作する方法は、各行がtechnicly詳細を持っています+正常細胞。
最後に詳細行のための私ができるようにするためにセルの数の属性COLSPANを与えることが行ごとに行の種類を確認し、そして(他は空であるので)のみ必要なセルを表示描画それは行の幅をすべて取る。
私はそれをテストしていないのでgl & hf;)何か問題があるならば、コメントすることを躊躇しないでください。
必要に応じて調整してください。
通常のデータテーブルを作成するとしますが、詳細行の場合は、td: 'colspan = nbOfColumn'に属性を追加し、詳細をtdに入れます。 –
私はこの角度ジェスの世界を研究し始めています.JQueryの他にも、私は 'colspan = nbOfColumn'を検索しようとしました。しかし私は私を助けることができる具体的な何かを見つけませんでした、あなたは例がありますか? – user8223022
JSONの例を教えてもらえますか?サーバー側で働いていますか?あなたはJSONを生成していますか? –