【发布时间】:2020-02-06 01:38:23
【问题描述】:
在这种特定情况下,响应式 DataTable 插件和 Boostrap 4.3.1 存在问题:
我有一个显示表格的超大模式,该表格有 3 个折叠列,其中包含一些联系信息,这可以按预期工作:
但是,在移动显示中,表格不会像我预期的那样折叠其他列,并且表格没有包裹在模态框内:
我在Datatables.net 使用了以下示例并加载了基本相同的文件,但 Bootstrap 是 4.3.1 版本而不是 4.1.3 版本除外。
我的 HTML:
<div class="modal fade bd-example-modal-xl" tabindex="-1" role="dialog" aria-labelledby="myExtraLargeModalLabel" id="modalOpciones" aria-hidden="true">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Opciones:</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<table id="tablaDirectorio" cellspacing="0" class="table table-striped table-bordered dt-responsive " style="width:100%">
<thead>
<tr>
<th>id</th>
<th>Nombre</th>
<th>Apellido</th>
<th>Departamento</th>
<th>Puesto</th>
<th>Fecha Creado</th>
<th>Extension</th>
<th class="none">Telefono</th>
<th class="none">Celular</th>
<th class="none">Email</th>
</tr>
</thead>
<tfoot>
<tr>
<th>id</th>
<th>Nombre</th>
<th>Apellido</th>
<th>Departamento</th>
<th>Puesto</th>
<th>Fecha Creado</th>
<th>Extension</th>
<th>Telefono</th>
<th>Celular</th>
<th>Email</th>
</tr>
</tfoot>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-dark" data-dismiss="modal">Cerrar</button>
</div>
</div>
</div>
</div>
我的 Javascript:
$('#opciones-list').on('click', 'a' ,(e) => {
$('#modalOpciones').modal('show');
var tablaEditar=$('#tablaDirectorio').DataTable({
"destroy": true,
"responsive":/*{
"details": {
renderer: function ( api, rowIdx, columns ) {
var data = $.map( columns, function ( col, i ) {
return col.hidden ?
'<tr data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+
'<td>'+col.title+':'+'</td> '+
'<td>'+col.data+'</td>'+
'</tr>' :
'';
} ).join('');
return data ?$('<table/>').append( data ) :false;
}
}
}*/true,
"autoWidth": false,
"ajax": {
"url": 'controller/controller.php',
"method": 'POST',
data:{accion:'getTabla'}
},
"columns": [
{"data": "directorio"},
{"data": "nombres"},
{"data": "apellidos"},
{"data": "departamento_nombre"},
{"data": "puesto"},
{"data": "fechacreado"},
{"data": "Extension"},
{"data": "Telefono"},
{"data": "Celular"},
{"data": "Email"}
],
"language":idioma_spanol,
"columnDefs": [
{"className": "dt-center", "targets": "_all"}
]
});
})
希望有人可以帮助我解决这个问题! 谢谢指教
【问题讨论】:
标签: jquery css bootstrap-4 datatables