最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Datatable columns width - Stack Overflow

programmeradmin4浏览0评论

I've set up a datatable with several rows and columns and would like to know how can I make the "Tel. 1, Tel. 2 and Fecha" columns a little wider so that the text shows in a single line. I've tried chaging the s width, and the columnsdef property on the datatable js, but it doesn't work.

    <html>

<head>

    <!DOCTYPE html>

    <script src=".12.0.min.js"></script>
    <script src=".10.11/js/jquery.dataTables.min.js"></script>
    <script src=".1.2/js/dataTables.select.min.js"></script>
    <script src=".1.2/js/dataTables.buttons.min.js"></script>
    <script src=".0.2/js/dataTables.responsive.min.js"></script>
    <link rel="stylesheet" href=".10.11/css/jquery.dataTables.min.css">
    <link rel="stylesheet" href=".1.2/css/select.dataTables.min.css">
    <link rel="stylesheet" href=".1.2/css/buttons.dataTables.min.css">
    <link rel="icon" href="./resources/logo.jpg">
    <link rel="stylesheet" href=".0.2/css/responsive.dataTables.min.css">




<script>


    $(document).ready(function() {


        var oTable = $('#maintable').dataTable( {

            "aoColumnDefs": [
                { "bSortable": false, "aTargets": [ 0 ] }
            ],
            "aaSorting": [[1, 'asc']],
            "scrollY": 500,
            "scrollX": true,
            "bAutoWidth": false,
            "aoColumns" : [
                { sWidth: '10px' },
                { sWidth: '100px' },
                { sWidth: '120px' },
                { sWidth: '30px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' }
            ],  



            "language": {
                "lengthMenu": "Mostrar _MENU_ datos por pagina.",
                "zeroRecords": "Nada fue encontrado.",
                "info": "Mostrando _PAGE_ de _PAGES_",
                "infoEmpty": "No hay datos disponibles",
                "infoFiltered": "(filtrado de _MAX_ datos totales)",
                "search": "Buscar:",
                "paginate": {
                    "first":      "Primero",
                    "last":       "Ultimo",
                    "next":       "Proximo",
                    "previous":   "Previo"
                }
            }


        });



    } );


</script>   




    <title>Consulta de facturas atrasadas</title>

    <style type="text/css">
        html, #page { padding:0; margin:0;}
        body { margin:0; padding:0; width:100%; color:#959595; font:normal 12px/2.0em Sans-Serif;} 
        h1, h2, h3, h4, h5, h6 {color:darkblue; text-align: center;}

        #page { background:#fff;}
        #header, #footer{ margin:0; padding:0;}


        #logo { padding:0; width:auto; text-align: center; margin: auto;}

        #header { background:#fff; }
        #header-inner { margin:0 auto; padding:0;}


        #footerblurb { background:#d3d3f9;color:blue; width: 100%;}     

        #footer { background:#fff; width: 100%;}
        #footer-inner { margin:auto; text-align:center; padding:12px;}
        #footer a {color:blue;text-decoration:none;}

        #maintable {

            text-align: center;             
            overflow: auto;
        }

        #events {
            margin-bottom: 1em;
            padding: 1em;
            background-color: #f6f6f6;
            border: 1px solid #999;
            border-radius: 3px;
            height: 100px;
            overflow: auto;
        }

        td.highlight {
            background-color: whitesmoke !important;
        }


        #container {

            width:90%;
            margin: 0 auto;

        }

        #titulo {

            margin: 0 auto;

        }


        div.slider {
            display: none;
        }

        table.dataTable tbody td.no-padding {
            padding: 0;
        }


        .bodycontainer { max-height: 450px; width: 100%; margin: 0; overflow-y: auto; }




        .clr { clear:both; padding:0; margin:0; width:100%; font-size:0px; line-height:0px;}

    </style>

</head>

<body>

        <br>
    <div id="page">
        <header id="header">
            <div id="header-inner"> 
                <div id="logo">

                </div>

                <div id="titulo">

                </div>

                <div class="clr"></div>
            </div>
        </header>
        <br>    

    <div id="container">

        <table id="maintable" class="row-border hover order-column display" cellspacing="0" width="100%">
            <thead>
                <tr style="text-align: center; color: black">

                    <th>Codigo</th>
                    <th>Nombre</th>
                    <th>Propietario</th>
                    <th>Direccion</th>
                    <th>Ciudad</th>
                    <th>Sector</th>
                    <th>Cedula</th>
                    <th>Tel. 1</th>
                    <th>Tel. 2</th>
                    <th>Celular</th>
                    <th>Factura</th> 
                    <th>Fecha</th> 
                    <th>Dias</th> 
                    <th>Monto</th> 
                    <th>Pendiente</th> 
                    <th>Vendedor</th> 

                </tr>
            </thead>


            <tbody>

                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOSE HERNANDEZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2016-4-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOSE HERNANDEZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2016-4-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOSE HERNANDEZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2016-4-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOSE HERNANDEZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2016-4-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOSE HERNANDEZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2016-4-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>

            </tbody>

        </div>    


        </table>    

    </div>                                                                      

    <div class="clr"></div>




</body>

I've set up a datatable with several rows and columns and would like to know how can I make the "Tel. 1, Tel. 2 and Fecha" columns a little wider so that the text shows in a single line. I've tried chaging the s width, and the columnsdef property on the datatable js, but it doesn't work.

    <html>

<head>

    <!DOCTYPE html>

    <script src="https://code.jquery./jquery-1.12.0.min.js"></script>
    <script src="https://cdn.datatables/1.10.11/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.datatables/select/1.1.2/js/dataTables.select.min.js"></script>
    <script src="https://cdn.datatables/buttons/1.1.2/js/dataTables.buttons.min.js"></script>
    <script src="https://cdn.datatables/responsive/2.0.2/js/dataTables.responsive.min.js"></script>
    <link rel="stylesheet" href="https://cdn.datatables/1.10.11/css/jquery.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables/select/1.1.2/css/select.dataTables.min.css">
    <link rel="stylesheet" href="https://cdn.datatables/buttons/1.1.2/css/buttons.dataTables.min.css">
    <link rel="icon" href="./resources/logo.jpg">
    <link rel="stylesheet" href="https://cdn.datatables/responsive/2.0.2/css/responsive.dataTables.min.css">




<script>


    $(document).ready(function() {


        var oTable = $('#maintable').dataTable( {

            "aoColumnDefs": [
                { "bSortable": false, "aTargets": [ 0 ] }
            ],
            "aaSorting": [[1, 'asc']],
            "scrollY": 500,
            "scrollX": true,
            "bAutoWidth": false,
            "aoColumns" : [
                { sWidth: '10px' },
                { sWidth: '100px' },
                { sWidth: '120px' },
                { sWidth: '30px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' },
                { sWidth: '120px' }
            ],  



            "language": {
                "lengthMenu": "Mostrar _MENU_ datos por pagina.",
                "zeroRecords": "Nada fue encontrado.",
                "info": "Mostrando _PAGE_ de _PAGES_",
                "infoEmpty": "No hay datos disponibles",
                "infoFiltered": "(filtrado de _MAX_ datos totales)",
                "search": "Buscar:",
                "paginate": {
                    "first":      "Primero",
                    "last":       "Ultimo",
                    "next":       "Proximo",
                    "previous":   "Previo"
                }
            }


        });



    } );


</script>   




    <title>Consulta de facturas atrasadas</title>

    <style type="text/css">
        html, #page { padding:0; margin:0;}
        body { margin:0; padding:0; width:100%; color:#959595; font:normal 12px/2.0em Sans-Serif;} 
        h1, h2, h3, h4, h5, h6 {color:darkblue; text-align: center;}

        #page { background:#fff;}
        #header, #footer{ margin:0; padding:0;}


        #logo { padding:0; width:auto; text-align: center; margin: auto;}

        #header { background:#fff; }
        #header-inner { margin:0 auto; padding:0;}


        #footerblurb { background:#d3d3f9;color:blue; width: 100%;}     

        #footer { background:#fff; width: 100%;}
        #footer-inner { margin:auto; text-align:center; padding:12px;}
        #footer a {color:blue;text-decoration:none;}

        #maintable {

            text-align: center;             
            overflow: auto;
        }

        #events {
            margin-bottom: 1em;
            padding: 1em;
            background-color: #f6f6f6;
            border: 1px solid #999;
            border-radius: 3px;
            height: 100px;
            overflow: auto;
        }

        td.highlight {
            background-color: whitesmoke !important;
        }


        #container {

            width:90%;
            margin: 0 auto;

        }

        #titulo {

            margin: 0 auto;

        }


        div.slider {
            display: none;
        }

        table.dataTable tbody td.no-padding {
            padding: 0;
        }


        .bodycontainer { max-height: 450px; width: 100%; margin: 0; overflow-y: auto; }




        .clr { clear:both; padding:0; margin:0; width:100%; font-size:0px; line-height:0px;}

    </style>

</head>

<body>

        <br>
    <div id="page">
        <header id="header">
            <div id="header-inner"> 
                <div id="logo">

                </div>

                <div id="titulo">

                </div>

                <div class="clr"></div>
            </div>
        </header>
        <br>    

    <div id="container">

        <table id="maintable" class="row-border hover order-column display" cellspacing="0" width="100%">
            <thead>
                <tr style="text-align: center; color: black">

                    <th>Codigo</th>
                    <th>Nombre</th>
                    <th>Propietario</th>
                    <th>Direccion</th>
                    <th>Ciudad</th>
                    <th>Sector</th>
                    <th>Cedula</th>
                    <th>Tel. 1</th>
                    <th>Tel. 2</th>
                    <th>Celular</th>
                    <th>Factura</th> 
                    <th>Fecha</th> 
                    <th>Dias</th> 
                    <th>Monto</th> 
                    <th>Pendiente</th> 
                    <th>Vendedor</th> 

                </tr>
            </thead>


            <tbody>

                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOSE HERNANDEZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2016-4-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOSE HERNANDEZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2016-4-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOSE HERNANDEZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2016-4-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOSE HERNANDEZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2016-4-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOSE HERNANDEZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2016-4-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>
                <tr>

                    <TD>02SA023</TD>      
                    <TD>MOTO REPUESTOS A Y J</TD>                                 
                    <TD>JOAN MANUEL RAMIREZ</TD>              
                    <TD>C/JOSE TAPIA BREA ANT.18 #249 ENS. QUISQUEYA</TD>         
                    <TD>SANTO DOMINGO</TD>                    
                    <TD>ENSANCHE QUISQUEYA</TD>               
                    <TD>00114957335</TD>                      
                    <TD>829-433-5307</TD>      
                    <TD>829-305-0426</TD>      
                    <TD>7195918</TD>
                    <TD>1718</TD>          
                    <TD>2015-12-18</TD>   
                    <TD>104</TD>                        
                    <TD>9980.00</TD>        
                    <TD>9980.00</TD>        
                    <TD>Joan Ramirez</TD>   

                </tr>

            </tbody>

        </div>    


        </table>    

    </div>                                                                      

    <div class="clr"></div>




</body>

Share Improve this question edited Nov 5, 2021 at 19:45 Heretic Monkey 12.1k7 gold badges61 silver badges131 bronze badges asked Apr 19, 2016 at 16:53 AdrianJGAdrianJG 531 gold badge4 silver badges11 bronze badges 1
  • try start prevent line breaking -> stackoverflow./questions/30535609/… – davidkonrad Commented Apr 19, 2016 at 17:05
Add a ment  | 

3 Answers 3

Reset to default 2

Try changing table-layout to fixed, By just adding this CSS:

table.display {
    table-layout: fixed;          
}

Now the new width values will applied as you need, I hope it works for you, Thanks.

You can read about Table-Layout CSS property for more information.


in your case when you are using "bAutoWidth": false, you need to set all columns width manually, instead of your method of using "aoColumns" you can do it like this:

"aoColumnDefs": [
   { "bSortable": false, "aTargets": [ 0 ] },
   { "sWidth": "50px", "aTargets": [0,1,2,3,4,5,6,9,11,12,13,14,15] },
   //            ^ Same width for all columns ( excluding Tel.1, Tel.2 and Fecha ).
   { "sWidth": "80px", "aTargets": [7,8,10] },
   //            ^ Width for 3 columns you want.
],

Your finaly oTable code looks like:

var oTable = $('#maintable').dataTable( {
        "aoColumnDefs": [
            { "bSortable": false, "aTargets": [ 0 ] },
            { "sWidth": "50px", "aTargets": [0,1,2,3,4,5,6,9,11,12,13,14,15] },
            { "sWidth": "80px", "aTargets": [7,8,10] },
        ],
        "aaSorting": [[1, 'asc']],
        "scrollY": 500,
        "scrollX": true,
        "bAutoWidth": false,

        "language": {
            "lengthMenu": "Mostrar _MENU_ datos por pagina.",
            "zeroRecords": "Nada fue encontrado.",
            "info": "Mostrando _PAGE_ de _PAGES_",
            "infoEmpty": "No hay datos disponibles",
            "infoFiltered": "(filtrado de _MAX_ datos totales)",
            "search": "Buscar:",
            "paginate": {
                "first":      "Primero",
                "last":       "Ultimo",
                "next":       "Proximo",
                "previous":   "Previo"
            }
        }
    });

Simply add this line inside columDefs:

"columnDefs": [
{ "width": "20%", "targets": [7,8,10] }
]

7, 8 and 10 are the indexes of the columns (Tel 1, Tel 2 and Fecha) in your case.

try this

"columnDefs": [
{ "width": "100px", "targets": "_all" }
]
发布评论

评论列表(0)

  1. 暂无评论