How to only show specific columns in ui-grid.js

I have json data (REST response) with many (partly nested) parameters but only want to show specif ones.

How to hide all and enable only specific ones? Currently all parameters are shown as columns.

So I do not want to hide one-by-one by excludeParameters or columnDef visible = false (because the list of parameters can be different based on REST response).

Do you have any idea? My intension is to change the default visibility to false and only the wanted parameters to true (via columnDef visible). Any solution for that?

Thanks in advance, Chris

Upvotes: 0

Views: 1025

Answers (1)

selftaught91
selftaught91

Reputation: 7481

My table options looks like this

    $scope.tableOptions= {

            data : [],
            columnDefs :[
                { field : 'firstName'},
                { field : 'middelName'},
                { field : 'lastName' }
            ]
     }

and I am using the directive as

<div ui-grid="tableOptions"></div>

the data will be populated inside the data field of $scope.tableOptions once the rest api fetches result

Each Json object in my case is having more than 10 fields but the table is only showing three fields which I have defined in columnDefs

Upvotes: 0

Related Questions