Permalink
Browse files

feat(sorting): make nested sorting configurable

  • Loading branch information...
VMBindraban
VMBindraban committed Apr 10, 2017
1 parent 9e2484a commit df5001883501ccf73fd8bad0bf89394943673511
Showing with 9 additions and 3 deletions.
  1. +5 −0 doc/usage.md
  2. +2 −2 src/bootstrap/datatable.html
  3. +2 −1 src/datatable.js
@@ -170,6 +170,11 @@ Or
<datatable populate.bind="['user','group']"></datatable>
```
### sortNested (Online mode only)
This allows you to sort on associations.
By default this is set to `false` because some back-ends don't support this.
### actions
Allow the user to add custom action buttons in case he needs more than just `edit` and/or `destroy` on the rows.
@@ -35,10 +35,10 @@
<!-- Labels -->
<th click.delegate="doSort(columnLabel)" repeat.for="columnLabel of columnLabels">
<!-- Just show the label -->
<span if.bind="sortable === null || columnLabel.nested || offlineMode" t="${columnLabel.label}">${columnLabel.label}</span>
<span if.bind="sortable === null || offlineMode || (columnLabel.nested && !sortNested)" t="${columnLabel.label}">${columnLabel.label}</span>
<!-- Show label and make it sortable (click) -->
<a if.bind="sortable !== null && !columnLabel.nested && !offlineMode">
<a if.bind="sortable !== null && !offlineMode && (!columnLabel.nested || sortNested)">
<span t="${columnLabel.label}">${columnLabel.label}</span>
<i class="fa fa-${criteria.sort[columnLabel.column] ? (criteria.sort[columnLabel.column] === 'desc' ? 'caret-down' : 'caret-up') : 'sort'}">
</i>
@@ -28,6 +28,7 @@ export class DataTable {
@bindable loadingIndicator = '<center>Loading...</center>';
@bindable populate = false; // Which columns to populate. True for all, string for specific.
@bindable detailView = false; // Detail viewmodel
@bindable sortNested = false; // Sort on nested properties (should be available server-side)
@bindable select; // User provided callback, called upon clicking on a row.
@bindable repository;
@bindable resource;
@@ -211,7 +212,7 @@ export class DataTable {
let column = columnLabel.column;
if (this.sortable === null || !this.isSortable(column)) {
if (this.sortable === null || (!this.isSortable(column) && !this.sortNested)) {
return;
}

0 comments on commit df50018

Please sign in to comment.