In AngularJS ui-grid , how can I configure the grid so that it can auto adjust the width of the columns according to the contents when it render?
I know there is a tutorial showing the auto size function, but that works only when you double click the column, I wish it could happen when the grid is initiated.
use an asterisk in your column definition:
width:"*";
There is a pluggin that do this: ui-grid-auto-fit-columns
GitHub: https://github.com/Den-dp/ui-grid-auto-fit-columns
Example: http://jsbin.com/tufazaw/edit?js,output
Usage:
<div ui-grid="gridOptions" ui-grid-auto-fit-columns></div>
angular.module('app', ['ui.grid', 'ui.grid.autoFitColumns'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With