[SalesForce] How to set lightning:datatable fixed column widths

I'm trying to set the column widths for lightning:datatable, but I don't see anywhere in the documentation on how to do this. I was thinking of tinkering with minColumnWidth and maxColumnWidth and see if it would auto-adjust to my liking, but as of August 2018, this functionality is broken

I have a datatable that has many columns that can be very skinny, while other columns should be much bigger. Right now, everytime the page loads, the column widths are evenly distributed.

Best Answer

You can use the initialWidth property of the column to set the width when it is rendered. It can still be resized.

[
    { label: 'Message', fieldName: 'Description', type: 'text' },
    {   
        type:  'button',
        initialWidth: 34,
        typeAttributes: {
            iconName: 'utility:new_window',
            name: 'newWindow', 
            title: 'Popout Window', 
            disabled: false, 
            value: 'test'
        }
    }
]