Skip to content

pagination sort

Pierre Besson edited this page Jan 16, 2015 · 4 revisions

View

Just use a list-view or a result-view.

Template

In your list, the columns should have a column sorted in order to do so, you have to use the helper sortColumn.

<thead>
  {{sortColumn "property" translationKey="translation.property"}}
  {{sortColumn "property2" translationKey="translation.property2"}}
</thead>

Service

In order to call the pagination service.

var promisify = Focus.Helpers.promisifyHelper;
var loadEntityListByCriteria = function(criteria, pageInfos){
   if (!_.isObject(userCriteria)) {
    throw new ArgumentInvalidException('criteria should be an object');
  }
  if (!_.isObject(pagesInfos)) {
    throw new ArgumentInvalidException('pageInfos should be an object');
  }
  var URL_ENTITY_SEARCH = require('../URL').URL_ENTITY_SEARCH;
  return promisify.collection(URL_ENTITY_SEARCH)
                  .search({criteria: criteria, pageInfos: pageInfos});
}

Collection

How to handle default sort on a list and the default name on the list.

var CollectionCustom = Focus.Models.PaginationCollection.extend({
//Name for the export columns.
exportColumnLabels: {
  "propertyName": "translation.key"
}
//Default sort on fields 
sortField: { 
    field: "fieldName", 
    order: "asc" 
  };
})
Clone this wiki locally