@knu2xs wrote:
Sorting, it should be easy. Sadly, it has me completely flummoxed. I am simply trying to sort records (reaches in my case) based on the river name and name fields in a data store named reaches. Just make sure I am not missing anything, here is my entire controller.
import Controller from '@ember/controller'; import { computed } from '@ember/object'; export default Controller.extend({ // linking the url to the query params in the field queryParams: ['search'], search: '', // sort the reaches so they appear in logical order sortFields: ['riverName:asc', 'name:asc'], modelSorted: computed.sort('reaches', 'sortFields'), actions: { // this prevents pressing enter from submitting and reloading the page preventSubmit(evt) { evt.preventDefault(); return false; }, } });
Nothing is showing up when I try to display the results in my template.
{{#each modelSorted as |reach|}} <tr> <td> {{#link-to 'reach' reach.id}} {{reach.riverName}} - {{reach.name}} {{#if reach.riverAlternateName}} ({{reach.riverAlternateName}}) {{/if}} ({{reach.difficulty}}) {{/link-to}} </td> </tr> {{/each}}
Incidentally, it was working, just not sorted, when referencing he model directly, so I am really confused. If it is relevant, I am using Ember 2.16.2 with Ember Data 2.16.3. What am I missing?
Posts: 4
Participants: 2