Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#372 allow sortable(false) on fields in list view #984

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -9,7 +9,7 @@
"url": "git://github.com/marmelab/ng-admin.git"
},
"devDependencies": {
"admin-config": "^0.11.0",
"admin-config": "^0.12.0",
"angular": "~1.4.8",
"angular-mocks": "~1.4.8",
"angular-numeraljs": "^1.1.6",
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