generating unique uids when column object is cached
This is an odd but fairly serious bug that occurs when the user swaps out the columndefs array entirely but there are elements in this new array that share the same attribute as the previous columndefs array -- see this plunkr: http://plnkr.co/edit/LUFGq2Ri35xlewpPXqYW?p=preview
simply click swap, and watch the table disintegrate
In the above, the two schemes that the user swaps between both share the 'name' column. Due to the fact that the default uses 'track by col.colDef.name' the column isnt recompiled and subsequently the class isnt refreshed to reflect the new uid given to the column. What is refreshed to reflect the uid is the customStyles used to compile the inline css.
I see. If you supply the name property rather than the field property it works as expected. Is that an option?
oh, thats interesting, thats certainly a better workaround than I am using (I just removed the track by).
The col class stays the same as well, meaning that setting the field col causes a new uid generation (presumably due to some cache lookup somewhere?) whereas name doesn't?
@c0bra: would this be related to #1948?
I've tried the plunker again and it's no longer exhibiting any bad behavior. I just fixed #1948 but the patch hasn't been released into unstable yet so the fix must have come from somewhere else!
@MeMea66 can you confirm that you haven't altered the plunker and it appears to be fixed? Thanks!
it still seems broken to me, it works as is because it is using the name property, if you switch the name property back to field it is still broken on the latest unstable
Is it because you're using the same field name twice without giving them unique names?
right, The issue I think is that the ngrepeat tracks by the name field so the same column object is used, but a unique uid is generated for the column. This creates a mismatch in the css where the column object expects a css class for the old uid but it no longer exists
So what should we do if you supply { field: 'name' }, { field: 'name' }? Use an incrementing naming system like 'Name', 'Name2' for uniqueness?
That's what I went ahead and did.