angular-data-table
angular-data-table copied to clipboard
Options vs Attributes
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) {}
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.
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
This is basically a two part feature.
- Gives users the ability to express methods directly on the options
- 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
I'll write up the sudo code here in a bit.
@jsheely sorry never got around to this, is this still causing issues for you?
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.