Fixed width columns

Fixed width columns

ThemicsterThemicster Posts: 1Questions: 0Answers: 0
edited August 2009 in General
I am using datatables to list emails, but I have a problem with displaying data in a fixed width table. I've tried applying css styles overflow: hidden; but it always seems to dynamically set the width of the column to the size of the data. How can I make the column width fixed?

Thanks,
Michael

Replies

  • antivanityantivanity Posts: 6Questions: 0Answers: 0
    From the docs at http://datatables.net/usage

    Defining the width of the column, this parameter may take any CSS value (3em, 20px etc). DataTables applys 'smart' widths to columns which have not been given a specific width through this interface ensuring that the table remains readable.

    01.$(document).ready(function() {
    02. $('#example').dataTable( {
    03. "aoColumns": [
    04. { "sWidth": "20%" },
    05. null,
    06. null,
    07. null,
    08. null
    09. ]
    10. } );
    11.} );
  • torenwaretorenware Posts: 3Questions: 0Answers: 0
    edited August 2009
    Deleted; dumb mistake on my part :-)
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    The other way to make sure that DataTables lets the browser do what it wants is to set http://datatables.net/usage#bAutoWidth . But if you do this, you will most likely want to give column widths in the HTML or in aoColumns as antivanity suggests.

    Just noticed that this is an old post reawakened - but more information can only be good information :-)

    Allan
  • ffdezffdez Posts: 10Questions: 2Answers: 0
    hi!

    I can not operate the parameter swidth

    [code]
    $('#021::1').dataTable( {
    "oLanguage": {
    "oPaginate": {
    "sFirst": "Primera",
    "sPrevious": "Anterior",
    "sNext": "Siguiente",
    "sLast": "Ultima"
    },
    "sProcessing": "Trabajando ...",
    "sLengthMenu": "Mostrar _MENU_ registros por pagina",
    "sZeroRecords": "Upss, no hemos encontrado nada",
    "sInfo": "Mostrando _START_ - _END_ de _TOTAL_ registros",
    "sInfoEmtpy": "Ningun registro",
    "sInfoPostFix": "",
    "sSearch": "Buscar:",
    "sInfoFiltered": "(filtrado desde un total de _MAX_ registros)"
    },
    "bSortClasses": false,
    "bStateSave": true,
    "bAutoWidth": false,
    "sPaginationType": "full_numbers",
    "sDom": '<"top"fp>rt<"bottom"li<"clear">',"aaSorting":[[3,'asc']],
    "aoColumns": [
    { "bSortable": false, "bSearchable": false, "sWidth": "10px" },
    { "bSortable": false, "bSearchable": false, "sWidth": "10px"},
    { "bSortable": false, "bSearchable": false, "sWidth": "10px"},
    {"sWidth": "50px"},
    {"sWidth": "100px"},
    null,
    null,
    null
    ]
    } );
    });
    [/code]
  • ffdezffdez Posts: 10Questions: 2Answers: 0
    I have solved. the table had a class that did not allow to resize the cells
This discussion has been closed.