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

Re-using a grid with new data/columns

Open specialjyo opened this issue 13 years ago • 3 comments

I'm using ng-grid to pull tables from a db and view/edit them. Since I dont have to define a column model, ng-grid is perfect. However, I would like to use the same grid instance over and over, and update the data and columns. Right now, when you update the data being referenced in the grid options object, it does indeed update the data, but the old columns remain. Simple way to reset a grid that I missed in the docs?

specialjyo avatar Feb 20 '13 13:02 specialjyo

currently, for this to work you would need to specify columnDefs (very simple {field: "prop"} would be sufficient. and then overwrite the column definitions when you change the data model.

We can take a look at adding support, possibly a "rebuildColumns" method or something like that to help facilitate this.

orneryd avatar Feb 20 '13 17:02 orneryd

Ok, great. It would appear that since I have no idea what columns are coming back, I'll have to preprocess the data, get the data object's keys and use those as column definitions, and overwrite both the data and column defs. I may be over simplifying that, but I'll give this a shot, thanks again!

specialjyo avatar Feb 20 '13 19:02 specialjyo

This would really be great. Currently I'm trying to push new ColumnDefs dynamically, but it doesn't work as expected :(. So :+1: (p.s.: Any Roadmap for this feature? :) )

Forget it: already found a solution: https://github.com/angular-ui/ng-grid/issues/36

Donderda avatar Mar 08 '13 13:03 Donderda