lundi 16 octobre 2017

How to update the `sorting` oder by different value?

I do have 2 type of sorting values. on click I should need to update my sorting order and require to update html. But at present I am not getting any update.

one is number scenario and other one is by date ( "07/07/2017" ).

here is my try: //not at all works!!

   sortByDateOfPurchase: Ember.computed(function(){
            return privateArray.sort(function(a,b){
                  console.log( b['date_of_purchase'] );
                  return  parseInt(b['date_of_purchase']) - parseInt(a['date_of_purchase']);//07/07/2017

            })
      }),

//works but not constant
      sortByAmountSpent:Ember.computed(function(){
            return privateArray.sort(function(a,b){
                  return  parseInt(b['amount-spent']) - parseInt(a['amount-spent']);
            })
      }),

      sortTheCards(title){
//changing the sorted array but not working
            if(title=='amountSpent'){
//setting for date value
                  this.set('sortedCards', this.get('sortByAmountSpent') );
                  return;
            }

            //setting for number value
            this.set('sortedCards', this.get('sortByDateOfPurchase') );


      },

    selectedDetails : [],
    transactionService: Ember.inject.service(),

      filterValue:Ember.observer('filterBy', function(){

            var sortBy = this.get('filterBy');
            this.sortTheCards( sortBy );

      }),

      init() {
            this._super(...arguments);
            this.set('selectedDetails', this.get('transactionService.selectedTransactions'));

            var sortBy = this.get('filterBy');
            var nestedCards = this.get('nestedCards');

            this.sortTheCards( sortBy );


      },




Aucun commentaire:

Enregistrer un commentaire