Skip to content

Commit f5e88fc

Browse files
committed
Merge branch '372_disable_sort' of https://github.com/RichardBradley/ng-admin into RichardBradley-372_disable_sort
2 parents ef14153 + b095fe6 commit f5e88fc

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

doc/API-mapping.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ myApp.config(['RestangularProvider', function(RestangularProvider) {
205205
}]);
206206
```
207207

208+
(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).)
209+
208210
## Filtering
209211

210212
All filter fields are added as a serialized object passed as the value of the `_filters` query parameter. For instance, the following `filterView()` configuration:

doc/reference/Field.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ Create a new field of the given type. Default type is 'string', so you can omit
5353
Define the label of the field. Defaults to the uppercased field name.
5454

5555
* `editable(boolean)`
56-
Define if the field is editable in the edition form. Usefult to display a field without allowing edition (e.g for creation date).
56+
Define if the field is editable in the edition form. Useful to display a field without allowing edition (e.g for creation date).
57+
58+
* `sortable(boolean)`
59+
Define if the field is sortable in the list view (default `true`).
60+
(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.)
5761

5862
* `order(number|null)`
5963
Define the position of the field in the view.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"lib/"
1515
],
1616
"dependencies": {
17+
"admin-config": "~0.12.1",
1718
"angular": "~1.4.8",
18-
"admin-config": "0.12.1",
1919
"angular-numeraljs": "^1.1.6",
2020
"angular-sanitize": "^1.3.15",
2121
"angular-translate": "^2.11.0",

src/javascripts/ng-admin/Crud/list/maDatagrid.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ export default function maDatagrid() {
2626
<ma-datagrid-multi-selector toggle-select-all="toggleSelectAll()" selection="selection" entries="entries"/>
2727
</th>
2828
<th ng-repeat="field in fields() track by $index" ng-class="field.getCssClasses()" class="ng-admin-column-{{ ::field.name() }} ng-admin-type-{{ ::field.type() }}">
29-
<a ng-click="datagrid.sortCallback(field)">
29+
<a ng-if="field.sortable()" ng-click="datagrid.sortCallback(field)">
3030
<span class="glyphicon {{ sortDir() === 'DESC' ? 'glyphicon-chevron-up': 'glyphicon-chevron-down' }}" ng-if="datagrid.isSorting(field)"></span>
3131
{{ field.label() | translate }}
3232
</a>
33+
<span ng-if="!field.sortable()">
34+
{{ field.label() | translate }}
35+
</span>
3336
</th>
3437
<th ng-if="datagrid.shouldDisplayActions" class="ng-admin-column-actions" translate="ACTIONS"></th>
3538
</tr>

0 commit comments

Comments
 (0)