Opened 6 years ago

Closed 3 years ago

#17227 closed enhancement (patchwelcome)

JsonRest add sortOptions member

Reported by: Herman Vierendeels Owned by: Kris Zyp
Priority: undecided Milestone: 1.11
Component: Data Version: 1.9.0
Keywords: Cc:
Blocked By: Blocking:

Description

Would it be possible to add sortOptions: to JsonRest?.

e.g. for store-queries that should always have sort-parameter

//sortOptions: Array e.g
// [{attribute:"tmstmp",descending:true}]

query: function(query, options){
options = options || {};
....

if(! options.sort){
 if(this.sortOptions){
  options.sort=this.sortOptions;
 }
}
                
if(options && options.sort){
....

}

by the way, why is there if(options && options.sort)

options is ensured to exist by initial statement:

options = options || {};

Or am i totally wrong?

Change History (4)

comment:1 Changed 6 years ago by bill

Component: GeneralData
Owner: set to Kris Zyp

comment:2 Changed 6 years ago by ben hockey

this sounds like something you could do with a subclass of JsonRest?

declare(JsonRest, {
  query: function (query, options) {
    options = options || {};
    options.sort = options.sort || this.sortOptions;
    return this.inherited(arguments, [query, options]);
  }
});

given that, maybe it's not right to put it into JsonRest? itself?

comment:3 Changed 6 years ago by Herman Vierendeels

yes indeed this could be done by subclassing.

but i think that , being able to set sortOptions for all queries, is a rather general requirement.

comment:4 Changed 3 years ago by dylan

Milestone: tbd1.11
Resolution: patchwelcome
Status: newclosed

Will consider for dstore ( http://dstorejs.io/ ). A pull request is welcome for dojo/store.

Note: See TracTickets for help on using tickets.