Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4826

How to achieve ArrayController sort functionality from controller in Ember 2.1.8

$
0
0

@Thilina_Dinith_Fonse wrote:

I have a model where there are relationships which are async=true and i have multiple properties like that.

code is used to do the sorting using arraycontroller where those hasmany async true relationships were not loaded. so how to achieve the same thing from controller which is bring up by ember 2.x?

this is under computed property

    var coordinators = this.get( 'model.coordinators' ),
    var  professors   = this.get( 'model.professors' ),
    
        coordinators.forEach( function( person ) {
    
            people.pushObject( Ember.Object.create( { person:person, id:person.id, role:'coordinators', title:'Coordinator', selected:false } ) ); } );

  if ( getFilter === 0 || getFilter === 1 ) {

      tabPeople.pushObjects( people.filterBy( 'role', 'coordinators'));
      tabPeople.pushObjects( people.filterBy( 'role', 'directors' ));

    }
    
    arrayController = Ember.ArrayController.create( {
        model: tabPeople,
       sortProperties: [ 'person.lastName' ],
      sortAscending: true
        } );

tabPeople is an array of models which is created with a computed property. this arrayController passed to another computed property to filter some results after sorting.

model

  coordinators: DS.hasMany( 'profile', { async: true } ),
  directors: DS.hasMany( 'profile', { async: true } ),
  professors: DS.hasMany( 'profile', { async: true } ),
  students: DS.hasMany( 'profile', { async: true } ),
  advisors: DS.hasMany( 'profile', { async: true } ),

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles