Skip to content
Permalink
Browse files

fix(customActions): handle disabled button on the fly

  • Loading branch information...
jeremyvergnas committed Jun 29, 2016
1 parent cc50b6f commit 21b919ffec3e5d7c7bcb99a7aa4c355cae74ae8a
Showing with 9 additions and 2 deletions.
  1. +1 −1 src/bootstrap/datatable.html
  2. +8 −1 src/datatable.js
@@ -64,7 +64,7 @@
<i class="fa fa-trash"></i>
</button>

<button repeat.for="action of actions" t="[title]action.title" title.bind="action.title || ''" disabled.bind="action.disabled" class="btn btn-sm btn-${action.type || 'default'}" click.delegate="doCustomAction(action, row)">
<button repeat.for="action of actions" t="[title]action.title" title.bind="action.title || ''" disabled.bind="checkDisabled(action, row)" class="btn btn-sm btn-${action.type || 'default'}" click.trigger="doCustomAction(action, row)">
<i if.bind="action.icon" class="fa fa-${action.icon}"></i>
<span if.bind="!action.icon && action.title" t="${action.title}">${action.title}</span>
</button>
@@ -102,11 +102,18 @@ export class DataTable {
}

doCustomAction(action, row) {
if (typeof action.action === 'function' && !action.disabled) {
if (typeof action.action === 'function') {
return action.action(row);
}
}

checkDisabled(action, row) {
if (typeof action.disabled === 'function') {
return action.disabled(row);
}
return false;
}

doSort(columnLabel) {
if (this.sortable === null || columnLabel.column.indexOf('.') !== -1) {
return;

0 comments on commit 21b919f

Please sign in to comment.
You can’t perform that action at this time.