I am trying to adjust the width of my header and columns because i plan to show the table on a mobile device. The column definitely got smaller by using the following:
columns: [
{ data: 'provinceState', title: 'State', width: '2px' },
{ data: 'countryRegion', title: 'Country', width: '2px' }
]
MY JS CODE
const getNewCases = async() => {
const response = await fetch('https://covid19.mathdro.id/api/daily/3-18-2020');
const data = await response.json();
let usa = data.filter(val => {
return val.countryRegion === 'US';
});
$('#loadingLabel').hide();
$('#myTable').DataTable({
data: usa,
bLengthChange: false,
bPaginate: false,
scrollY: '50vh',
columns: [
{ data: 'provinceState', title: 'State', width: '2px' },
{ data: 'countryRegion', title: 'Country', width: '2px' }
]
});
};
getNewCases();
As you can see in my FIDDLE my datatable body has gotten smaller but the headers have not. Is there a proper way to ensure that both get smaller? Am i doing something wrong?
FYI I also tried the accepted answer in this stackoverflow Post