Permalink
Browse files

feat(project): Add specific routes for each column

  • Loading branch information...
jeremyvergnas committed Nov 29, 2016
1 parent 02d9192 commit 1393b5cc492b5beab71e5b8f69935189b910b771
Showing with 18 additions and 2 deletions.
  1. +2 −1 src/bootstrap/datatable.html
  2. +16 −1 src/datatable.js
@@ -57,7 +57,8 @@
<!-- Columns -->
<td repeat.for="columnLabel of columnLabels">
<a click.delegate="selected(row)" innerhtml.bind="displayValue(row, columnLabel.column) | convertManager: columnLabel.converter"></a>
<span if.bind="!columnLabel.route && !route && !select" innerhtml.bind="displayValue(row, columnLabel.column) | convertManager: columnLabel.converter"></span>
<a if.bind="route || select || columnLabel.route" click.delegate="selected(row, columnLabel)" innerhtml.bind="displayValue(row, columnLabel.column) | convertManager: columnLabel.converter"></a>
</td>
<!-- Actions -->
@@ -236,6 +236,7 @@ export class DataTable {
nested : !this.isSortable(column.property),
column : column.property,
label : ucfirst(clean(column.label || column.property)),
route : column.route || false,
converter: column.valueConverters || false
};
});
@@ -275,7 +276,21 @@ export class DataTable {
return this.element.dispatchEvent(new CustomEvent(event, payload));
}
selected(row) {
selected(row, columnOptions) {
if (columnOptions.route) {
let params = {};
if (columnOptions.route.params) {
Object.keys(columnOptions.route.params).forEach(param => {
let property = columnOptions.route.params[param];
params[param] = this.displayValue(row, property);
});
}
return this.router.navigateToRoute(columnOptions.route.name, params);
}
if (this.route) {
return this.router.navigateToRoute(this.route, {id: row.id});
}

0 comments on commit 1393b5c

Please sign in to comment.