angular-data-table icon indicating copy to clipboard operation
angular-data-table copied to clipboard

Options vs Attributes

Open jsheely opened this issue 9 years ago • 6 comments

What are your thoughts on anything that can be declared as an attribute can be expressed in the options?

For example. on-row-click="method(row)"

What if that could be

$scope.options {
      onRowClick: myRowClickHandler
}
function myRowClickHandler(row) {}

jsheely avatar Jan 20 '16 15:01 jsheely

Ya, I've thought about it. I wanted to keep the api expressive though. You could probably just do something like:

for(let meth from this.attributes){ this.bind.... }

I'd be ok w/ it.

amcdnl avatar Jan 20 '16 16:01 amcdnl

Not sure I followed you on that last code sample.

My thought was to re-write each controller to handle questioning the options for a value or method that matches and use that if a attribute does not exist

onRowClicked(row){
if(this.onRowClick!=undefined) {
    this.onRowClick({
      row: row
    });
} else if(this.options.onRowClick!=undefined) {
    this.options.onRowClick.call(this, {row:row});
}

Seudo code but something like that

jsheely avatar Jan 20 '16 16:01 jsheely

This is basically a two part feature.

  1. Gives users the ability to express methods directly on the options
  2. Allow users to manipulate the inner working variables

My initial problem was I didn't have access to the header checkbox list so if I select all items then delete all selected items. The checkbox remains checked in the header and I have no way to un-check it. https://github.com/Swimlane/angular-data-table/pull/134

jsheely avatar Jan 20 '16 16:01 jsheely

I'll write up the sudo code here in a bit.

amcdnl avatar Jan 20 '16 16:01 amcdnl

@jsheely sorry never got around to this, is this still causing issues for you?

amcdnl avatar Apr 07 '16 12:04 amcdnl

Yes, the feature described would be very useful when working with row and external frameworks. For instance, if you want to have an attribute on the row from Angular Material you could do something like:

$scope.options = {
  rowAttributes: {
    mdSwipeLeft: swipeLeftHandler
  }
}

and it would add the following attribute to the row:

<div class="dt-row ng-scope dt-row-even" ... md-swipe-left="swipeLeftHandler(row)">
</div>

This would be a solution to issue #107.

ghost avatar Apr 07 '16 14:04 ghost