Wie setze ich Datatable in modal?
Hier ist mein Code, habe ich versucht, JQuery DataTable
in Bootstrap-modal aufzunehmen.
HTML
<div class="col-lg-12">
<div class="modal fade" style="height: 100%;" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" style="width:90%;">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">
<div class="modal-kepala"></div></h4>
</div>
<div class="modal-body">
<div class="modal-badan"></div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
</div>
<!-- /.col-lg-12 -->
</div>
JS
$('.modal-badan').append('<table class="table datatable" id="dataTables-example">'+
'<thead>'+
'<tr>'+
'<th>ID</th>'+
'<th>Pelapor</th>'+
'<th>Waktu</th>'+
'<th>Judul</th>'+
'<th>Kategori</th>'+
'<th>Status</th>'+
'<th>Publish</th>'+
'<th>Detail</th>'+
'</tr>'+
'</thead>'+
'<tbody>'+
laporan+
'</tbody></table>');
$('#dataTables-example').DataTable();
} else {
$('.modal-badan').append('<table class="table table-striped table-bordered table-hover" id="dataTables-example">'+
'<thead>'+
'<tr>'+
'<th>ID</th>'+
'<th>Pelapor</th>'+
'<th>Waktu</th>'+
'<th>Judul</th>'+
'<th>Kategori</th>'+
'<th>Status</th>'+
'<th>Publish</th>'+
'<th>Detail</th>'+
'</tr>'+
'</thead>'+
'<tbody>'+
'</tbody>');
$('.modal-badan').append('</table><script type="text/javascript">$("#dataTables-example").DataTable({ responsive: true });<\/script>');
}
Was möchten Sie ...? –
Ich möchte Datatable in der Modalität, aber meine Datatable äußere Modal .. –
@ RahmatSaepuloh, bitte posten Sie Ihre HTML, um Ihnen zu helfen. –