Re-show hidden column in ui-grid AngularJs
Asked Answered
P

1

8

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,

Pagoda answered 9/7, 2015 at 11:25 Comment(0)
D
15

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' }
    ],
    ...
  };
Doris answered 9/7, 2015 at 17:44 Comment(1)
Thanks Kanthir for your useful help.I added that example in ng-grid just for make myself clear for what I really want. I was searching for the equivalent of showColumnMenu in ui-grid but I did not find it.Pagoda

© 2022 - 2024 — McMap. All rights reserved.