[Please help] Datatables fixed with columns.
[Please help] Datatables fixed with columns.
sarbjitbillingfico
Posts: 1Questions: 0Answers: 0
Can anyone help with the following problem? I’m trying to create a Datatable with fixed width columns.
1. If I specify 10px for the column width, Datatables resizes the columns to occupy the full page width.
2. If I specify an outer container. Datatables seems to set the column width close to the desired width.
Is there any way of forcing Datatables to set the correct width without the need for an outer container?
Thanks,
Sarb
$(document).ready(function () {
$('.my-table').dataTable({
bAutoWidth: false,
aoColumnDefs: [
{
"aTargets": [0],
sWidth: '10px'
},
{
"aTargets": [1],
sWidth: '10px'
}
]
});
});
<!-- example 1 -->
A
B
1
2
<!-- example 2 -->
A
B
1
2
1. If I specify 10px for the column width, Datatables resizes the columns to occupy the full page width.
2. If I specify an outer container. Datatables seems to set the column width close to the desired width.
Is there any way of forcing Datatables to set the correct width without the need for an outer container?
Thanks,
Sarb
$(document).ready(function () {
$('.my-table').dataTable({
bAutoWidth: false,
aoColumnDefs: [
{
"aTargets": [0],
sWidth: '10px'
},
{
"aTargets": [1],
sWidth: '10px'
}
]
});
});
<!-- example 1 -->
A
B
1
2
<!-- example 2 -->
A
B
1
2
This discussion has been closed.