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

Child components as Parent properties in Blazor #12095

Closed
furqansafdar opened this issue Jul 11, 2019 · 1 comment
Closed

Child components as Parent properties in Blazor #12095

furqansafdar opened this issue Jul 11, 2019 · 1 comment
Labels
area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one ✔️ Resolution: Duplicate Resolved as a duplicate of another issue

Comments

@furqansafdar
Copy link

furqansafdar commented Jul 11, 2019

How to create a DataGrid component that can specify GridColumns as shown in the code below:

<DataGrid Items="@GridData">
    <DataGridColumns>
        <DataGridColumn Field="OrderId" Header="Order Id" Width="100"></GridColumn>
        <DataGridColumn Field="OrderDate" Header="Order Date" Width="120"></GridColumn>
    </GridColumns>
</DataGrid>

DataGrid is a templated component definition is as below:

@typeparam TItem
 
@functions {
    [Parameter] RenderFragment GridColumns { get; set; }
    [Parameter] IReadOnlyList<TItem> Items { get; set; }
}

Till now i have been able to get the Contents in DataGridColumns property. But my intent is to get the each DataGridColumn as collection to customize the rendering of the HTML by looping through each element but so far i am unable to work out how to approach this solution.

Desired HTML rendering for example:

<div>
    <colgroup>
        <col style="width: 100px;">
        <col style="width: 120px;">
    </colgroup>
    <thread>
        <tr>
            <th>
                <div style="text-align: right;">
                    <span>Order Id</span>
                </div>
            </th>
            <th>
                <div style="text-align: right;">
                    <span>Order Date</span>
                </div>
            </th>
        </tr>
    </thread>
    <!-- ... Rest of the HTML ... -->
</div>
@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one labels Jul 11, 2019
@mkArtakMSFT
Copy link
Member

Thanks for contacting us, @furqansafdar.
This is not very straight-forward currently. We plan to make this experience much better as part of #7268.
For now, you can have a look how community has created similar components.

@mkArtakMSFT mkArtakMSFT added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Jul 12, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 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 enhancement This issue represents an ask for new feature or an enhancement to an existing one ✔️ Resolution: Duplicate Resolved as a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants