angular-ui/ui-grid

CellTemplate directive disassociated with row data

Open

#4,869 opened on Dec 16, 2015

View on GitHub
 (22 comments) (2 reactions) (0 assignees)JavaScript (5,395 stars) (2,496 forks)batch import
help wantedseverity: performance

Description

I'm trying to understand the cause of what seems to be a known issue the use of directives in cellTemplate.

I have logic which examines a nested array, if any of these array objects have a status of 'prohibited' I am rendering 'prohibited' in that grid cell. When I execute this logic within a $filter it works fine but if I put this logic in the link (or controller) of my directive it only works proper for the first ~20 rows. Once you begin scrolling, or sort the grid, the column rendering the directive becomes disassociated with the rest of the data. I have executed a similar test as proposed here and have found that $scope.row.entity is indeed disassociated with the actual row being rendered.

While I can work around this issue via the $filter approach it feels dirty since I'll also be wrapping the 'prohibited' string in dom elements to add styling.

If need be I can create a plunkr to demonstrate what I'm seeing.. but at this point I am certain the issue arises when the filtering logic is executed inside the directive. Even calling the actual $filter inside the directive causes this issue. Yet I can call the $filter via cellFilter or directly in the markup of the cellTemplate (cellTemplate:'{{MODEL_COL_FIELD | MyFilterHere}}') without issue.

Contributor guide