lundi 15 octobre 2018

How to achieve ArrayController sort functionality from controller in Ember 2.1.8

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 } ),




Aucun commentaire:

Enregistrer un commentaire