Reputation: 63
I'm facing an issue where ng-grid data does not display on column resizing, when column names change.
Created a plunkr at - http://plnkr.co/edit/eV9baoDOV9A46FZmKW8G?p=preview
Please note the below function in main.js to explicitly change the column names and corresponding data.
$scope.reload = function(){
$scope.columnDefinitions = [
{field: 'first_col'},
{field: 'second_col'}
];
$scope.myData = [{first_col: "colData1", second_col: "colData2"},
{first_col: "colData3", second_col: "colData4"},
{first_col: "colData5", second_col: "colData6"}
];
}
Steps -
Scenario 1 (works).
Scenario 2 (doesn't work)
Really stuck with this issue. Any help will be much appreciated.
Upvotes: 3
Views: 1392
Reputation: 1483
It seems the width of the column is not getting picked up when you press change. If you manually define it, it will work :
{field: 'first_col', width: 200},
{field: 'second_col', width: 200}
From the ng-grid documentation :
Width can also be defined in percentages (20%, 30%), in weighted *s, or "auto" (which sizes the column based on data length) (much like WPF/Silverlight)/ note: "auto" only works in single page apps currently because the re-size happens on "document.ready". Still working on improving that.
So I'm guessing it's defaulting on "auto" and that's why it's not working. If you try putting "auto" (or anything %-based) as width, you'll also get the error. I suggest you use a workaround in the meantime.
Upvotes: 1