ng-src in cellTemplate
Hello,
I'm using a cellTemplate with ng-src in an image tag. I noticed some strange behavior when scrolling vertically. Plunker: http://plnkr.co/edit/WxxRyy9v2IXOTZ5Qg36x?p=preview
After scrolling all the way to the bottom and then scrolling up slowly, images suddenly appeared on "Image 12" and "Image 13" even though these 2 entries should not have any image associated to them.

It is very unusual. It looks like what it's doing is that as we scroll we create (reuse) the dom elements. At the point we generate the DOM element, we're evaluating your template:
"cellTemplate":"<div class=\"ui-grid-cell-contents ng-scope ng-binding\"><img ng-src=\"{{COL_FIELD}}\" border=\"0\" width=\"25\">"
I sort of feel like the {{COL_FIELD}} isn't quite right in an ng-src. What that should do is get replaced with grid.getCellValue(row, col), which you can see it is doing if you take the {{}} off the template. But it's kinda funny having a binding in an angular directive, it feels wrong but I can't articulate why it is wrong.
It feels more intuitive to me to go with a template of:
"cellTemplate":"<div class=\"ui-grid-cell-contents ng-scope ng-binding\"><img src=\"{{COL_FIELD}}\" border=\"0\" width=\"25\">"
which gives less funny scroll behaviour, but for me it's now not rendering image1 at all. Not sure why that is either. http://plnkr.co/edit/WxxRyy9v2IXOTZ5Qg36x?p=preview
Does that give you any hints to help progress? In looking at the element for image1, it appears to have a size of 0x0 pixels, but is actually there. Perhaps that's a different problem?
I started out with "src" instead of "ng-src" but that gave me a different issue.

I guess the error occurred because some of the rows do not have a value for image url (e.g. Image 4 onwards). Using "ng-src" seems to have fixed the issue but I ran into the scroll issue.
:+1:

I have the same issue with ng-class : expressions are not synchronized with the entity row.
<li ng-class='triangle c-etat{{row.entity.etat}}'">
- Use
src="{{ COL_FIELD }}". Using ng-src is causing the binding to not get updated. You're basically stacking two bindings on top of each other. - That image url is serving a 307 redirect to a data url containing a 1x1 pixel image. It does the same thing on codepen: http://codepen.io/anon/pen/NPwgEd
@mmouterde you don't use curly braces inside most (or all?) ng- directives.
The proper thing would be, I think:
<li ng-class='triangle c-etat' + row.entity.etat">
or
<li class='triangle c-etat{{ row.entity.etat }}">
@c0bra, you are absolutely right ! my mistake.
No worries!
I'm confused why this got closed. It seems like the initial issue is still outstanding.
Because the original issue was caused by user error, of a sort. You can't do ng-src="{{xxxx}}", you either do src="{{xxxxx}}", or you do ng-src="xxxxx". It isn't believed to be a grid defect.
Hi I just trying to show a glyphicon according the valu of a field. I did this in my columnDefs { name: 'has_picture', displayName : 'Has Picture', enableSorting: false, enableColumnMenu : false, enableCellEdit: false, cellTemplate: '
and my getPictureCellTemplate is ` $scope.getPictureCellTemplate = function(value, type) { var html = ''; if (value == 1) { if (type === 1) { html += ''; } else { html += ''; } }
console.log(html);
return html;
}
`
But in the cell, when i run my app the html code (<span class....) is shown...
Any hint to solve this
TIA, Yamil
I solve by myself. I just wrote cellTemplate: '
Regards,
Hi guys, I got the same problem. How should I do? I can't use: ng-src="" or src="{{COL_VALUE}}", both takes the: GET http://localhost:7777/grid.getCellValue(row,%20col) 404 (Not Found)
I wrote :
enableCellEdit: false, cellTemplate: '<div class="ui-grid-cell-contents">' + '<span ng-if="row.entity.has_picture == 1" class="glyphicon glyphicon-picture" data-placement="left" data-toggle="tooltip" title="Has Picture"></span> ' + '<span ng-if="row.entity.has_video == 1" class="glyphicon glyphicon-facetime-video" data-placement="left" data-toggle="tooltip" title="Has video"></span> ' + '<span ng-if="row.entity.has_extras == 1" class="glyphicon glyphicon-asterisk" data-placement="right" data-toggle="tooltip" title="Has Extras"></span> ' + '</div>' }, ...
Replacing ng-src="{{xxxxx}}" with src="{{xxxxx}}" worked for me.
Hi YamilBracho, I have the same requirement as your's. Can I have a working code demo of your provided code?