-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
DataSource: encapsulate displayColumns
#5883
Comments
The The benefit to the class is that we created an API that can be responsive to changes in the view (e.g. the user has scrolled and we can provide information on what rows are now viewed) as well as providing a hook such that the user can trigger rendering updates. With respect to why we didn't include I certainly agree that as of now, it would be a lot nicer API if columns were held by the If you're interested further into the design of the table and some of its rationale, please check out its design doc: https://docs.google.com/document/d/1ZyKhwrgqfTBAn7saTq2jPlep2_CwSw5DeoZ8UbaXrC0 |
@andrewseguin that all makes perfect sense as to why you'd want to keep the base That being said, I'm thinking it would still make sense to expose something like I mentioned the |
I could see a benefit in some use cases where the I'm not sure how this would reconcile with features such as sections (#5891 - consecutive sets of data with different columns and headers) or conditional rows (#5887 - the rows and event/attribute bindings are conditional on the row data). In these features, the rows themselves must understand what cells should be rendered and the I could imagine that as we develop sections, that the input for columns will only need to go to the section rather than to both the header row and data row templates, except conditional rows would still want to be able to override this. |
@andrewseguin my initial impression for #5891 would be that you'd have some new parent wrapper component like [edit]: it also seems likely that you'd probably want the ability to Without thinking about it in too much detail, I don't have a great answer for what this would mean concerning #5887. My first thought is that |
The split between the data source and the table exists to separate two fundamentally different responsibilities: what is the data, and how is the data displayed. The columns being displayed falls into the "display" category, and moving it to the data source would go against this separation of responsibilities. |
@jelbourn I think we're drawing somewhat arbitrary lines in the sand here while disregarding the implications to usability. I've already provided two example cases demonstrating when these responsibilities are in fact inseparable. This is especially true when we start talking about data-driven or otherwise dynamic columns. I might choose to load the display columns from a remote resource, local storage, etc, all of which might further be customized depending on row context. If we don't start encapsulating this functionality somewhere, components using I don't disagree that I would imagine we'll run into many of the same issues with If we want to talk about editable I think at the very least this issue warrants more discussion. |
The distinction isn't arbitrary. The question of "where does data come from" is genuinely a separate concern from "how is data rendered". The primary intent behind the idea of the data source is to leave all of the specifics about "where does data come from" to the user. This prevents us from doing anything with the data source that doesn't mesh well with any of the myriad of data sources out there; the only behavior baked into the data source itself is that which you literally couldn't render rows of cells without. We expect people to extend Another aspect to this is that a future enhancement to the table will be the addition of multiple row templates, each of which can have a different set of columns. For tree there actually is a |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
Proposal
What is the expected behavior?
I would like to propose that the
DataSource
class be used to encapsulate thecolumns
parameter in*cdkHeaderRowDef="columns"
and*cdkRowDef="let row; columns: columns"
.I haven't been able to find any documentation on the rationale behind the current
DataSource
implementation, but based on the usage examples, it seems like general purpose implementations ofDataSource
would benefit from having access to the column definitions.What is the current behavior?
Current behavior is that
displayColumns
is a property of the parent component and is not accessible to theDataSource
.What is the use-case or motivation for changing an existing behavior?
Given that the docs appear to encourage implementing filter functionality within
DataSource
, you could imagine a genericFilteredDataSource
that only applies search criteria to the visible columns.As mentioned above, a nice side-effect would be simplifying usage of
md-header-row
andmd-row
by having fewer required inputs.Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Material
v2.0.0-beta.8+
.Is there anything else we should know?
If nothing else it would be nice to get better documentation on the rationale behind
DataSource
and its intended use. Currently it doesn't seem to do enough to justify itself in the simple case. Better examples would also be helpful (#5848).The text was updated successfully, but these errors were encountered: