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

allow array of subparameter in blazor component, with generic type constraint #17194

Closed
julienGrd opened this issue Nov 18, 2019 · 6 comments
Closed
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@julienGrd
Copy link

Is your feature request related to a problem? Please describe.

This issue follow this one : #17092
I don't know how to really describe this, the idea is to allow have array sub component in a component wich was "automatically" typed with the generic parameter of a parent. Its better to read the issue in link to understand the problem

Describe the solution you'd like

The solution of @mrpmorris on this comment seem nice : #17092 (comment)

thanks !

@javiercn
Copy link
Member

We believe this issue is better described by #17200. If you are asking for a different thing, feel free to comment here and we will re-evaluate.

@julienGrd
Copy link
Author

I don't really know if we speak about the same thing, i will follow the 17200 and see the evolution

@mrpmorris
Copy link

mrpmorris commented Nov 18, 2019

We believe this issue is better described by #17200. If you are asking for a different thing, feel free to comment here and we will re-evaluate.

@javiercn I don't think it's the same thing.

This request is to allow the setting of a parameter like public MySubComponent[] { get; set;} as child content.

A good example of this would be a Grid<T> which would have a parameter public Column<T>[] Columns { get; set;}

<Grid Items=People>
  <Columns>
    <Column Data=@(x => x.FullName)/>
  </Columns>
</Grid>

At the moment there is no way for Column<T> to infer its type from Grid<T> because RenderFragments can contain absolutely anything.

This is a request from some kind of [ViewChild] and [ViewChildren] attributes which will let the developer specify only one type of content is allowed (a grid has columns, nothing else).

@javiercn
Copy link
Member

@mrpmorris You can have templated components that use RenderFragment<T> https://docs.microsoft.com/en-us/aspnet/core/blazor/components?view=aspnetcore-3.0#templated-components

@mrpmorris
Copy link

mrpmorris commented Nov 19, 2019

@javiercn that would be a single item. The request is for an array, at the moment it isn't possible to implement the grid/column example I gave using RenderFragment<T>

Here is a good example https://github.com/IvanJosipovic/BlazorTable/blob/master/src/BlazorTable.Sample/Pages/Index.razor#L20

See how every Column has to specify the generic TableItem? In "normal" C# you could infer this from the Table.

@mrpmorris
Copy link

@javiercn Could you reopen this, please? It's almost certainly not the same thing as the issue you linked to. This is a request for an array of strongly typed content, not render fragments.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

3 participants