You are having the same issue as my. I posted something similar here:
The problem is that the column menu works on the internal grid columns, not on your column definition.
$scope.$on('ngGridEventColumns', function (newColumns) {
//do work here to save the column information.
console.log('Columns changed');
console.log(newColumns.targetScope.columns);
$scope.updateGridLayoutOnServer(newColumns);
});
And then do a manually sync of the confiuration:
$scope.updateGridLayoutOnServer = function (newColumns) {
var mustUpdate = false;
angular.forEach($scope.columnsOptions, function (column, index) {
if (column.visible !== newColumns.targetScope.columns[index].visible)
{
mustUpdate = true;
column.visible = newColumns.targetScope.columns[index].visible;
}
});
if (mustUpdate) {
var newLayout = { columns: $scope.columnsOptions };
Service.updateGridLayout(newLayout); // send the new layout to the persistence store
};
};
You also have to add the visible property to your column options:
columnDefs: [
{ field:"name", displayName: "NAME", width: "140", visible: true},
{ field:"age", displayName: "AGE", width: "**", visible: true}]