Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9267939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:40:46+00:00 2026-06-18T14:40:46+00:00

Update #2 I found that when I refactored the filtering logic to take place

  • 0

Update #2

I found that when I refactored the filtering logic to take place in a compound computed property within the PostController instead of within individual routes, I was able to get it working. The solution was ultimately dependent upon a single dynamic variable set by the specific #linkTo route action that triggered filtering changes within a PostController computed property. I have a lot of work to catch up on so I can’t post the solution to this specific question now, but when I can I will detail an explanation of the solution below. For now I have marked @twinturbo’s answer as correct for the partial but incredibly helpful guidance he gave below. Thanks again man!! Much appreciated!!

Update #1

The latest fiddle is at http://jsfiddle.net/aZNRu/14/ with @twinturbo’s help, sorting the “rank” attribute of Comments in its Post parent controller is working, along with basic filtering. Still having the problem of not getting auto updating views when in a filtered route and a new comment is created.

Original Question

I see that there is talk of combining the sortable mixin with filtering functionality, but for now, as you can see in my jsfiddle example, I’m having issues with both sorting and filtering:

1) I can’t figure out how to sort by a specific child attribute in the controller of its parent. If we have:

App.Post = DS.Model.extend({
    title: DS.attr('string'),
    post: DS.attr('string'),
    comments: DS.hasMany('App.Comment')
});

App.Comment = DS.Model.extend({
    post: DS.belongsTo('App.Post'),
    description: DS.attr('string'),
    isActive: DS.attr('boolean'),
    rank: DS.attr('number')
});

App.Router.map(function() {
  this.resource("posts", { path: "/" }, function() {
    this.resource('post', { path: ':post_id' }, function() {
        this.route('active');
        this.route('inactive');
     });
   });
});

I want to be able to sort each post’s comments in ascending order by it’s “rank” attribute. I want to do something like:

App.PostController = Ember.ObjectController.extend({
    sortProperties: ['comments.rank']

but for one, I think sortProperties only works on arrayControllers, and I don’t think it can work more than one level deep. How could I achieve this?

2) The second problem is not getting auto-updating views when in a filtered route. For example, if you view the jsfiddle and go into the active filtered route by clicking “Active Comments” you get a nice filtering effect on the current data. But if you remain in the active route and create a new record that is active by clicking “Add New Comment,” the record does not automatically render under “Active,” and only appears if you click on another route and then return to it.

Am I setting up the route filtering incorrectly in the route or referencing it wrong in the template?

App.PostActiveRoute = Ember.Route.extend({
  setupController: function() {
    var post = this.controllerFor('post').get('model'),
    comments = post.get('comments');

    var activeComments = comments.filter(function(comment) {
      if (comment.get('isActive')) { return true; }
    });

    this.controllerFor('post').set('filteredComments', activeComments);
  }
});


<ul>
    {{#each comment in filteredComments}}
        <li>{{comment.rank}} {{comment.description}} - isActive: {{comment.isActive}}</li>
    {{/each}}
</ul>

Any insight you could give on these issues would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:40:47+00:00Added an answer on June 18, 2026 at 2:40 pm

    but for one, I think sortProperties only works on arrayControllers, and I don’t think it can work more than one level deep. How could I achieve this?

    You are correct that sortProperties only works on Ember.ArrayController.

    You really don’t need to do anything fancy to achieve this. Simply wrap the comments array in a new ArrayProxy that includes the sortable mixin. Then you can sort the comments. Then you don’t need a nest property because you’re sorting an array of comments.

    Please don’t extend DS.ManyArray. There is no need for that.

    As for sorting and filtering, you need to use composition here. That means creating something like filteredContent and sortedContent. Then you can have sortedContent use filteredContent.

    Update:

    PostController = Ember.ObjectController.extend({
      comments: (function() {
        return Ember.ArrayProxy.createWithMixins(Ember.SortableMixin, {
          sortProperties: ['rank'],
          content: this.get('content.comments')
        });
      }).property('content.comments')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found something that works with updating one field at here: http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-single-sql-query/ UPDATE person
Right guys, all autocomplete plugins and functions that I've found, they only update upon
Possible Duplicate: SQL ORDER BY total within GROUP BY UPDATE: I've found my solution,
UPDATE: I found that the easiest way is to use AQuery . I need
ETA UPDATE: I've found that if I remove all the transparent .png files from
I recently refactored an old project and found that a particular portion no longer
using Microsoft.SqlServer.Management.SqlStudio.Explorer; unable to find this pls assist [update] found the dll's in this
Update : I found almost exact similar question , yet it has slightly different
Update Solution Found See Bottom of post if interested Seems simple enough and for
12:18:55,541 INFO [UpdateChecker] New update(s) found: 2.0.0 [ http://ehcache.org/news.html] How do I suppress ehcache

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.