Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re-show hidden column in ui-grid AngularJs

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,

like image 936
I3i0 Avatar asked Jul 09 '15 11:07

I3i0


1 Answers

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' }
    ],
    ...
  };
like image 197
Kathir Avatar answered Nov 19 '22 10:11

Kathir