Skip to content

Commit

Permalink
marmelab#372 allow sortable(false) on fields in list view
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardBradley committed Apr 4, 2016
1 parent 8636a9c commit 30b5eee
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 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
28 changes: 16 additions & 12 deletions doc/reference/Field.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ A field is the representation of a property of an entity.
* [General Field Settings](#general-field-settings)
* `string` Field Type
* `text` Field Type
* [`wysiwyg` Field Type](#-wysiwyg-field-type)
* [`wysiwyg` Field Type](#wysiwyg-field-type)
* `password` Field Type
* `email` Field Type
* [`date` Field Type](#-date-field-type)
* [`datetime` Field Type](#-datetime-field-type)
* [`number` Field Type](#-number-field-type)
* [`date` Field Type](#date-field-type)
* [`datetime` Field Type](#datetime-field-type)
* [`number` Field Type](#number-field-type)
* `float` Field Type
* [`boolean` Field Type](#-boolean-field-type)
* [`choice` and `choices` Field Types](#-choice-and-choices-field-types)
* [`boolean` Field Type](#boolean-field-type)
* [`choice` and `choices` Field Types](#choice-and-choices-field-types)
* `json` Field Type
* [`file` Field Type](#-file-field-type)
* [`reference` Field Type](#-reference-field-type)
* [`referenced_list` Field Type](#-referenced-list-field-type)
* [`embedded_list` Field Type](#-embedded-list-field-type)
* [`reference_many` Field Type](#-reference-many-field-type)
* [`file` Field Type](#file-field-type)
* [`reference` Field Type](#reference-field-type)
* [`referenced_list` Field Type](#referenced-list-field-type)
* [`embedded_list` Field Type](#embedded-list-field-type)
* [`reference_many` Field Type](#reference-many-field-type)

## General Field Settings

Expand Down 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 @@ -9,7 +9,7 @@
"url": "git://github.com/marmelab/ng-admin.git"
},
"devDependencies": {
"admin-config": "git://github.com/RichardBradley/admin-config.git#a455071e",
"admin-config": "git://github.com/RichardBradley/admin-config.git#84311ee",
"angular": "~1.3.15",
"angular-bootstrap": "^0.12.0",
"angular-mocks": "1.3.14",
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,11 +26,14 @@ 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 {{ datagrid.sortDir === 'DESC' ? 'glyphicon-chevron-down': 'glyphicon-chevron-up' }}" ng-if="datagrid.isSorting(field)"></span>
{{ field.label() }}
</a>
<span ng-if="!field.sortable()">
{{ field.label() }}
</span>
</th>
<th ng-if="datagrid.shouldDisplayActions" class="ng-admin-column-actions">
Actions
Expand Down

0 comments on commit 30b5eee

Please sign in to comment.