Re-show hidden column in ui-grid AngularJs

I3i0 picture I3i0 · Jul 9, 2015 · Viewed 14.1k times · Source

I am using ui-grid in one of my projects and one of the requirement is to hide/show columns in the grid. Hiding columns working well but then how can I re-show the hidden column?

After searching awhile I found that in ng-grid there is showColumnMenu which provide the ability to show column after hiding it, see this example I found

$scope.gridOptions = {
data: 'myData',
columnDefs: [{
                field: "id",
                visible: false
            },{
                field: "name",
                displayName : "name"
            },{
                field: "age",
                displayname: "age",

            }] ,
multiSelect: false,
showGroupPanel: true,
selectedItems: [],
showColumnMenu: true };

, but in ui-grid using showColumnMenu is not working.

I was wondering if someone know how to show hidden columns.

Thanks,

Answer

Kathir picture Kathir · Jul 9, 2015

ng-grid is being re written as ui-grid. Your example link is pointing to ng-grid. But if you are wondering how to do this in angular-ui-grid.

http://plnkr.co/edit/In28bF2EYuQaATwqnBAn?p=preview Take a look at this example. To show the hidden the columns, you need to enableGridMenu, which will show you the option to show the hidden columns.

$scope.gridOptions = {
    exporterMenuCsv: false,
    enableGridMenu: true,        
    columnDefs: [
      { name: 'name' },
      { name: 'gender', enableHiding: false },
      { name: 'company' }
    ],
    ...
  };