Skip to content

Commit

Permalink
Merge branch '372_disable_sort' of https://github.com/RichardBradley/…
Browse files Browse the repository at this point in the history
…ng-admin into RichardBradley-372_disable_sort
  • Loading branch information
fzaninotto committed Dec 1, 2016
2 parents ef14153 + b095fe6 commit f5e88fc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions doc/API-mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ myApp.config(['RestangularProvider', function(RestangularProvider) {
}]);
```

(If a column is not sortable by your backend, e.g. a computed column, you can disable sorting per-column using [`Field.sortable(false)`](reference/Field.md#general-field-settings).)

## Filtering

All filter fields are added as a serialized object passed as the value of the `_filters` query parameter. For instance, the following `filterView()` configuration:
Expand Down
6 changes: 5 additions & 1 deletion doc/reference/Field.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ Create a new field of the given type. Default type is 'string', so you can omit
Define the label of the field. Defaults to the uppercased field name.

* `editable(boolean)`
Define if the field is editable in the edition form. Usefult to display a field without allowing edition (e.g for creation date).
Define if the field is editable in the edition form. Useful to display a field without allowing edition (e.g for creation date).

* `sortable(boolean)`
Define if the field is sortable in the list view (default `true`).
(See ["Sort Columns and Sort Order"](../API-mapping.md#sort-columns-and-sort-order) for a discussion of how to integrate `ng-admin` sorting with your REST backend.)

* `order(number|null)`
Define the position of the field in the view.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"lib/"
],
"dependencies": {
"admin-config": "~0.12.1",
"angular": "~1.4.8",
"admin-config": "0.12.1",
"angular-numeraljs": "^1.1.6",
"angular-sanitize": "^1.3.15",
"angular-translate": "^2.11.0",
Expand Down
5 changes: 4 additions & 1 deletion src/javascripts/ng-admin/Crud/list/maDatagrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ export default function maDatagrid() {
<ma-datagrid-multi-selector toggle-select-all="toggleSelectAll()" selection="selection" entries="entries"/>
</th>
<th ng-repeat="field in fields() track by $index" ng-class="field.getCssClasses()" class="ng-admin-column-{{ ::field.name() }} ng-admin-type-{{ ::field.type() }}">
<a ng-click="datagrid.sortCallback(field)">
<a ng-if="field.sortable()" ng-click="datagrid.sortCallback(field)">
<span class="glyphicon {{ sortDir() === 'DESC' ? 'glyphicon-chevron-up': 'glyphicon-chevron-down' }}" ng-if="datagrid.isSorting(field)"></span>
{{ field.label() | translate }}
</a>
<span ng-if="!field.sortable()">
{{ field.label() | translate }}
</span>
</th>
<th ng-if="datagrid.shouldDisplayActions" class="ng-admin-column-actions" translate="ACTIONS"></th>
</tr>
Expand Down

0 comments on commit f5e88fc

Please sign in to comment.