다음 코드가 있습니다.
$('input[name="select-all"]').click(function() {
//channel-data is initialised as DataTable
$('#channel-table').find('input[name="batch-select"]:checked').each(function () {
$(this).prop("checked",true);
});
});
1st 이외의 페이지에서 모두 선택 버튼을 클릭 할 때마다 데이터 테이블이 계속해서 첫 번째 페이지로 되돌아갑니다. 확인란 속성의 변경으로 인해 다시 그리기 때문에 발생한다고 생각합니다.
예, 아마도-그러나 가설을 테스트 할 이유를 보지 못했습니다. :) dataTables를 다룰 때 항상 API를 사용하십시오! every()
모든 행을 순환하고 체크 박스를 업데이트하는 데 사용할 수 있는 깔끔한 방법이 있습니다. 다음은 "모두 선택"버튼과 확인란을 사용하여 설정을 재현하려고 시도한 예입니다.
$('input[name="select-all"]').click(function() {
table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var $tr = this.nodes().to$()
$tr.find('input[name="batch-select"]').prop('checked', true)
})
})
데모-> http://jsfiddle.net/u9Lq56v1/
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다