angular-ui / ui-grid

UI Grid: an Angular Data Grid
http://ui-grid.info
MIT License
5.39k stars 2.47k forks source link

grid.cellValueGetterCache holding on too long #2780

Open brucemackenzie opened 9 years ago

brucemackenzie commented 9 years ago

rc.18 build I have a grid with two static columns and several more columns synthesized depending on the data I want to show (the 'view').

I have various data views, and sometimes the same column (same name) appears in two instances of the grid (these are log runs so the same log may appear in different categorizations).

If the column for a run is in the zero'th position on the first view and say fourth on a different view, the data in the fourth column was showing as a duplicate of the new data now appearing in the first column.

After scratching my head over this for several days, i finally dug into the grid logic and found the caching that caused my issue.

For me, renaming the columns so that each column name was unique for each view (even for the same data source) works around this behavior because the lookup is by name.

BTW - i tried the various notify functions to inform the grid that i'd made a change (after I excised the variable columns between view changes) but this did not seem to touch the cellValueGetterCache.

brucemackenzie commented 9 years ago

A picture should help. I altered my logic to insert [row,col] in each cell to diagnose the issue. gatekeeper-4268 was originally in the third column in this grid that is now apf-2015_02_09.... Notice how the apf column at top left shows [0,0] and so does the gatekeeper-4268 column:

screen shot 2015-02-14 at 9 57 39 am

c0bra commented 9 years ago

You should be able to use the same field over and over add long as you provide a unique name. If you don't price a name it will generate them and hopefully use incrementing names. That may only have arrived in rc19 though.

brucemackenzie commented 9 years ago

I tried rc19 but it didn't seem to help thought i was NOT providing a unique name. I figured when the columns were deleted, and i'd called notifyChange there would be no more saved state to worry about. Thanks for taking the time to look at this.

c0bra commented 9 years ago

@brucemackenzie sorry for not responding for so long.

Do you think I could reproduce this behavior by setting up a grid where I move one columnDef's position in the array and then replace the item in its previous position with a new columnDef?