나는 당신의 문제에 대해 읽었습니다 .... 나는 당신의 문제에 대한 또 다른 접근법을 취합니다. (항상 dom 조작 xD에 관한 것입니다 ...) 가장 똑똑하지는 않지만 내 생각에는 효과가 있다고 생각합니다.
- 나는 함수 내부에 datatables 조작을 넣어 내가 사업부 빈 사업부를
- 그런 다음 내가 갱신에 그 기능을
- 를 호출없이 테이블을 추가하고 테이블 datatbles 조작하기 전에이 같은 HTML을 추가하고 fill
- 그런 다음 ColReorder 플러그인이 업데이트 된 데이터와 함께 작동하여 전체 datatables를 다시 그리는 함수를 호출하십시오.
PS : http://jsfiddle.net/aKuHM/5이
이제 표는 다음과 같습니다 :
<div class="Example" id="Example">
<table id="myTable" class="datatable">
<thead>
</thead>
<tbody>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
그리고 당신의 JS 머리에 그것의 로딩을이 방법을 찾습니다 : 여기에 자세한 내용은 업데이트 된 바이올린은
data = [
['cell1', 'cell2','cell3','cell4','cell5','cell6','cell17', 'cell8', 'cell9', 'cell10'],
['cell1', 'cell2','cell3','cell4','cell5','cell6','cell17', 'cell8', 'cell9', 'cell10'],
['cell1', 'cell2','cell3','cell4','cell5','cell6','cell17', 'cell8', 'cell9', 'cell10'],
];
function Saludos(){
$(function(){
myTable = $('#myTable').dataTable({
"aoColumns": [
{"sTitle":"col0", "bSearchable": false, "bVisible": true},
{"sTitle":"col1", "bSearchable": false, "bVisible": true},
{"sTitle":"col2", "bSearchable": true, "bVisible": true},
{"sTitle":"col3", "bSearchable": true, "bVisible": true},
{"sTitle":"col4", "bSearchable": true, "bVisible": true},
{"sTitle":"col5", "bSearchable": false, "bVisible": true},
{"sTitle":"col6", "bSearchable": true, "bVisible": true},
{"sTitle":"col7", "bSearchable": false, "bVisible": true},
{"sTitle":"col8", "bSearchable": true, "bVisible": true,
"mRender": function (data, type, row){
return '<b><i>'+ row[8] +'</i></b>';
}
},
{"sTitle":"col9", "bSearchable": false, "bVisible": false},
],
"aaSorting": [[8, 'asc']],
"aaData": data,
"sScrollY": 200,
"sScrollX": "100%",
"sScrollXInner": "150%",
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": 'R<"H"lfr>t<"F"ip>',
"iFixedColumns": 3,
"oColReorder": {
"aiOrder": [ 0, 8, 2, 3, 4, 5, 6, 7, 1, 9 ]
}
});
$('#updatebutton').click(function(){
updateTable();
});
});
}
Saludos();
function updateTable(){
data[1][8] = "even bolder";
$('.Example').empty();
$("#Example").html("<table id='myTable' class='datatable'><thead></thead> <tbody></tbody><tfoot></tfoot></table>");
Saludos();
console.log(data);
}
json 배열을 사용하고 있습니까? – Hackerman
아니요, 일반 배열이며 각 행에 대한 배열이 있습니다. (필드 이름이없고 단지 [[cell1, cell2], [cell3, cell4]] 데이터입니다 .json과 관련된 작업이 있습니까? – Jeroen
js 어레이에 대한 설명서를 보았습니까? http : //www.datatables. net/examples/data_sources/js_array.html – Hackerman