sproutcoresproutcore-views

sproutcore orderBy other controller


in one of my ListViews I display besides several 'office' properties a 'distance' property belonging to an other controller and the orderBy is only working for/with the 'office' model properties.

Background: I have an input field for an postalcode used in a query to get the distances between this postalcode and all of our office postalcodes. The obtained distances are in a second controller.

Please some advice how to get the distance orderBy working.


Solution

  • The easiest would be to add a computed property to the model which retrieves the distance from the controller in which you have the information. In order for the orderBy to work, it needs to seem to the array controller / list view combination that the property you want to sort on is a property of the object displayed.