'auto' column widths do not work
Unless I am missing something, setting a column width to 'auto' does not work any longer. Based on the documentation I found for this feature (https://github.com/angular-ui/ng-grid/wiki/Defining-columns), I assumed it would size the column to the size of its cells' contents. However, it seems to be always be set to the same really small width.
Here is a simple example of what I am seeing: http://plnkr.co/edit/1l2dwY?p=preview
why set any width? (ie. let it auto-size it for you from available space). Or are you purposely trying to set the width to the largest cell value? In my tables I used fixed widths for columns that are known sizes (like quantity, price, icon columns etc.) and then use either % or do not define a width for the rest and let the size appropriately. So far I have been happy with their layout (plus a user can resize if needed)
I'm sure I could figure out a different way to accomplish what I am looking for and in the meantime that is what I will have to do. However, I still think the 'auto' width feature is currently broken and would nice just to be able to use that. Otherwise, (if it isn't broken) I would like to know how to properly use the 'auto' width feature.
Is there any estimate on when this issue will be addressed?
I'm looking at this right now.
So... I know what the problem is.
On initial load, this can't do anything because... it's called too early. This plunk illustrates it, there's a debugger set right after the call to $utils.getElementsByClassName so it's stopping execution right after the call. You don't need to look for very long to see that there aren't going to be any "col1" classed elements to measure against.
Now to fix it.
@roblarsen - any word on whether this is getting fixed?
The real question is not whether, but when I'm busy this week, but will be able to look at this and a few other issues next week some time.
Great, thank you. Highly appreciate it.
I am waiting for this issue to resolve. I have column for messages of varying sizes so need to adjust the width based on widest message in all rows.
Any word on the progress on this? Thank you!
I am also working on a project that needs this.
Just going to also say this seems like a useful functionality to have! thanks for looking into fixing it!
any news about this issue ? is there a temp solution until this issue fixed ?
Just wondering if this is still being worked on or was it put in the too hard basket?
Not too hard. Just not being worked on at present.
Is there an ETA? Just wondering if I should starting looking for an alternative?
Hi I have a UI that is switching back and forth from grid view to treemap view. once I change the model in the treemap view and switch back to grid - all columns were shrink-ed until the columns get the update. This is very bad UX.... will appreciate a solution. Thanks Charlie.
a workaround would also be appreciated.
workaround : you can add to the gridOptions init function like this : $scope.gridOptions = { ... init: function (gridCtrl, gridScope) { gridScope.$on('ngGridEventData', function () { $timeout(function (){ angular.forEach(gridScope.columns, function (col) { gridCtrl.resizeOnData(col); }); }); }); } }
thanks you still did not work for me...:)