Skip to content
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

Implicit creation of rows when new data added to model? #52

Closed
schickm opened this issue Jun 13, 2016 · 7 comments
Closed

Implicit creation of rows when new data added to model? #52

schickm opened this issue Jun 13, 2016 · 7 comments

Comments

@schickm
Copy link

schickm commented Jun 13, 2016

I've noticed that you have to manually call table.addRow() if you'd like a new row to appear in the table. Is it possible to have the table watch the initial passed in model to the constructor for changes? Or is adding rows at runtime not really a priority feature for this table addon?

@RobbieTheWagner
Copy link
Member

@schickm I just use the didReceiveAttrs hook to set the rows, so the rows are set anytime the model changes. I think it makes sense to do this rather than relying on the addon to do it.

@schickm
Copy link
Author

schickm commented Jun 24, 2016

Gotcha, but I was thinking of a scenario where my component receives a RecordArray as the model. At some point in the future records are added/removed from the RecordArray due to changes in the store. This would mean that didReceiveAttrs wouldn't be triggered since technically the attribute was the RecordArray instance, not it's content.

Hopefully I'm making sense here... If there was a way to demonstrate this using an ember twiddle I'd love to...but looks like the ember twiddle folks are still working on addon support

I guess I could use one of those dreaded observers that everyone tells me not to use... Thanks for getting back to me!

@RobbieTheWagner
Copy link
Member

@schickm are you sure it wouldn't fire? You may be right, since our model is slightly different, and is a model with an array as just one property inside it, but when we load more records into the store, and they are pulled into that array, the didReceiveAttrs hook is called.

@offirgolan
Copy link
Collaborator

@schickm as of right now, implicit row creation is not on the backlog. Maybe in the future but the current goal of this addon is to focus mostly on the table component rendering and give you all the power on when and how rows/columns are added/removed/modified. Ill leave this open for now so that way I wont forget!

@schickm
Copy link
Author

schickm commented Jun 24, 2016

@offirgolan makes sense, I got that feeling from looking at the API. If/when I get a good non-observer based approach to this, I'll post it here for others interested.

@taras
Copy link
Collaborator

taras commented Jun 25, 2016

@schickm I create a PR #79 that adds a table helper that you can use to automatically update the table when data changes. This will only work for simple tables as the moment. I'm working on some secret sauce that'll make this a viable solution for complicated tables. Give it a shot and let me know if it works for you.

@offirgolan
Copy link
Collaborator

Done! (#167) 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants