How to autowidth one column of the table?

How to autowidth one column of the table?

jstuardojstuardo Posts: 99Questions: 40Answers: 0

Hello,

I have a datatable with this column definition:

     `columns: [
                { data: "Texto", width: '100%' },
                { data: "Fecha", width: 100 },
                { data: "Latitud", width: 100 },
                { data: "Longitud", width: 100 },
                { data: "Altitud", width: 100 }
            ],`

All columns should have a fixed with of 100px but Texto, which has to occupy the rest of the grid width.

Table HTML is this:

<table id="registros" class="table table-striped table-bordered nowrap"> <thead> <tr> <th>Elemento</th> <th>Fecha</th> <th>Latitud</th> <th>Longitud</th> <th>Altitud</th> </tr> </thead> </table>

This code causes the last column, Altitud, to be hidden.

I tried by using data-priority="0" attribute but always a column is hidden.

The screen resolution is width enough to be able to show all columns.

An help, please?

Thanks
Jaime

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @jstuardo ,

    The columns.width when used as a percentage should total 100%, not each be 100%. You could set them correct at the start, then if the page size changes, call columns.adjust() to ensure the ratio is recalculated.

    Hope that helps,

    Cheers,

    Colin

This discussion has been closed.