Hi, im working with the server side editor. All works great, now im tring to set the columns width. I read all the dcumentation, and nothing works for me. I try with
$('#example').dataTable( {
"columnDefs": [
{ "width": "20%", "targets": 0 }
]
} );
or with "autoWidth": false.
I only want to give some columns a fixed width.
Heres is my code
$('#example').DataTable( {
"columnDefs":
[
{ "searchable": false, "targets": [6,0] },
],
"footerCallback": function( thead, data, start, end, display ) {
$(thead).find('th').eq(0).css({"background-color":"#C8ECA9"})
},
"footerCallback": function( tfoot, data, start, end, display ) {
$(tfoot).find('th').eq(0).html("");
$(tfoot).find('th').eq(1).html("");
$(tfoot).find('th').eq(2).html("");
$(tfoot).find('th').eq(3).html("");
$(tfoot).find('th').eq(4).html("");
$(tfoot).find('th').eq(5).html("");
$(tfoot).find('th').eq(6).html("");
$(tfoot).find('th').eq(7).html("");
},
responsive: true,
"pageLength": 30,
"processing": true,
dom: "Tfrtip",
ajax: {
url: "examples/php/staff.php",
type: "POST"
},
serverSide: true,
columns: [
{ data: null, defaultContent: '', orderable: false, class:"center" },
{ data: "empresa", "width": "40%" },
{ data: "nombre" },
{ data: "direccion", "width": "40%" },
{ data: "localidad" },
{ data: "tel" },
{ data: "mail", "searchable": false },
{ data: "nombre2" },
{ data: "codp" },
{ data: "provincia" },
{ data: "web" },
{ data: "cel" },
{ data: "rubro" },
{ data: "cuit" },
{ data: "notas" },
],order: [ 1, 'asc' ],
tableTools: {
sRowSelect: "os",
sRowSelector: 'td:first-child',
sSwfPath: "TableTools/swf/copy_csv_xls_pdf.swf",
aButtons: [
{ sExtends: "editor_create", editor: editor },
{ sExtends: "editor_edit", editor: editor },
{ sExtends: "editor_remove", editor: editor },
{
sExtends: "collection",
sButtonText: "Exportar",
sButtonClass: "save-collection hidden-xs",
aButtons: [ 'copy', 'csv', 'xls', 'pdf' ]
},
{
sExtends: "print",
sButtonText: "Imprimir",
sButtonClass: "hidden-xs",
sInfo: "Presiones la tecla 'Escape' para salir"
},
]
},
} );
} );
Thanks