How do I ensure the datagrid expands to the total columns width or shrinks to the minimum table width on adding/removing columns?Using refreshColumnWidths() after add/remove columns has no effect.
If you want the width to be constant (a better option from the UI perspective, in my opinion), set the width of your DataGrid once and set width of at least one column in percentages. After you add or remove columns DataGrid will automatically resize columns to fit its width.
Minimum width setting is useful when you set width of your DataGrid as a percentage of its parent widget or add it to a layer of a resizable panel. When a browser window (or other content) forces DataGrid to change its size, it will automatically resize its columns until it hits the minimum width, at which point a horizontal scrollbar will appear and columns will not be resized anymore.