Closed awildeep closed 10 years ago
You're right. This is because in order to update that computed property I'd need to observe 'rows.@each.sortedFieldName'
. So basically, I'd have to set up and/or teardown observers dynamically. Here's a jsbin demonstrating that: http://emberjs.jsbin.com/xegus/1/edit?html,js,output
Of course that doesn't really relate to the idea of "composable components" which was the real purpose of this example.
The basic idea: In lieu of a computed property, use two observers to dynamically setup an observer that updates the the sorted results... so..
I've added branch "step4" with changes to show how one might work around an issue like this.
Again, this fix doesn't at all relate to the actual topic this project was created for, but hopefully it helps someone.
@blesh I completely agree with you. I really wish GitHub had a "This would be really nifty, but not required" tag to add to issues.
I appreciate the effort though. Thanks.
No problem.
@blesh you could also use Ember.computed.sort which will do this for you.
Hey thanks for the example. I am just curious if it would be possible to have the incrementNumber action trigger the table sort?
For example, if you sort by the "Number" column, and click a number it will increase the value of the number in that cell. The current iteration does not reapply the sorting if the number incremented rises to a point where the column is no longer sorted.
I am not seeing an obvious way to do this (which may be why it is not included).