You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the cellTemplate.html uses {{COL_FIELD CUSTOM_FILTERS}} form, if a non-string object is passed to it, the toJSON function is called and it returns a quoted string. These quotes are hard to get rid of in the cells.
One reason one might need such an object is for aiding in sorting, since the sortFn does not get the complete row context.
This problem as can be seen in the Time Spent column here (plunker). The labels here are double quoted. Here, we want to show the labels but the sort function should depend on the actual number of seconds.
The SortableValue class here implements the toJSON function, which returns the label.
This problem can be fixed easily by switching to an ng-bind, as shown here (plunker).
In this case, the SortableValue class needs to implement toString function.
I think you've provided a succinct description of the issue. The "investigation" would be whether or not the code change to use ng-bind is better or if simply documenting this case and leaving the code alone is better.
For what it's worth, IMO, leaving the code alone would restrict the the effective use of the sortFn without resorting to monkey-patching string objects in the field to hold the true values on which to sort by.
Perhaps there is another, and more correct, way of passing context to the sortFn that I do not know of?
Since the
cellTemplate.html
uses{{COL_FIELD CUSTOM_FILTERS}}
form, if a non-string object is passed to it, thetoJSON
function is called and it returns a quoted string. These quotes are hard to get rid of in the cells.One reason one might need such an object is for aiding in sorting, since the
sortFn
does not get the complete row context.This problem as can be seen in the Time Spent column here (plunker). The labels here are double quoted. Here, we want to show the labels but the sort function should depend on the actual number of seconds.
The
SortableValue
class here implements thetoJSON
function, which returns the label.This problem can be fixed easily by switching to an
ng-bind
, as shown here (plunker).In this case, the
SortableValue
class needs to implementtoString
function.The change required was relatively minor.
I can make a pull request with this commit if this solution is acceptable. All tests pass with this change.
However, could this be an angular bug?
The text was updated successfully, but these errors were encountered: