-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass table object into cellComponent #150
Comments
@billdami from my experience, including the It seems as though you are not the only person to need this feature, as it could def. reduce code complexity and keep custom components more modular. I should have some more time to add this feature hopefully this or next week. |
@offirgolan Thanks for reviewing this! Yeah I see the argument for not wanting to pass the table instance around too much, although it seems like in some cases you really do want to do table-level things from the context of a cell (such as in my example, deleting/removing the row). Maybe that particular use case could solved another way though, perhaps a The reason it makes it a bit messy for me to accomplish this with the if I had access to the table object in the cell component that was executing the delete action, I could bypass the table component completely, by directly calling the appropriate action provided in tableActions which returns a promise, and when it resolves, call init() {
this.get('tableActions').removeRow = Ember.$.proxy(this.get('actions').removeRow, this);
}
...
actions {
removeRow(row) {
if(this.attrs.removeRow) {
this.attrs.removeRow(row.get('content')).then(() => {
this.get('table').removeRow(row);
});
}
}
} |
@taras what do you think of this? Solutions proposed:
|
👍 For my use case, #2 would obviously be perfect, though I'm not sure if others have scenarios which would be simplified by having access to |
Resolved with #163 |
If possible, it would be nice to able to have access to the
table
object within a custom cell component, for example, to have "delete row" button cell component which callstable.removeRow(row)
. Currently, I'm defining an action on tableActions within the parent component'sinit()
that the cell component invokes, but it seems a bit messy.I noticed that the table object does get passed to custom column components (https://github.com/offirgolan/ember-light-table/blob/master/addon/templates/components/columns/base.hbs#L2). Any reason why we couldn't do the same for the cell components?
The text was updated successfully, but these errors were encountered: