ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Generating ColumnDefs dynamically

Open Shiti opened this issue 12 years ago • 3 comments

Is there a way to build ColumnDefs everytime the data changes?

In my case, different columns may be returned from the server and need to displayed in the same container.

I could create ColumnDefs from that data every time I change data but just wanted to know if there is an option like "dynamicColumn" which takes boolean and ensures that columnDefs are built again when data is changed(since we anyways watch the data).

Shiti avatar Jan 14 '14 06:01 Shiti

If you set the columnDef property to a string, ng-grid puts a watcher on the corresponding object, as you are most likely doing with data as well.

So, if you have the object $scope.myColumnDef that you wanted to use dynamically, set the columnDef propery to be 'myColumnDef'

linkmastr001 avatar Jan 15 '14 15:01 linkmastr001

Currently, I am generating columnDefs again but I wanted to know if there is an option so that columnDefs is generated automatically.

Shiti avatar Jan 16 '14 05:01 Shiti

Ah, I see what you're asking for now. If you don't define them, they are auto generated. No idea what happens if you added a column to the data with undefined columns...

linkmastr001 avatar Jun 13 '14 19:06 linkmastr001