Skip to content

Add CascadingTypeParameter for automatic ItemType inference in GridView/DataGrid columns#320

Merged
csharpfritz merged 4 commits intodevfrom
copilot/pass-itemtypes-to-children
Jan 31, 2026
Merged

Add CascadingTypeParameter for automatic ItemType inference in GridView/DataGrid columns#320
csharpfritz merged 4 commits intodevfrom
copilot/pass-itemtypes-to-children

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 31, 2026

GridView and DataGrid required redundant ItemType specification on every child column component (BoundField, TemplateField, HyperLinkField, ButtonField), creating verbose markup prone to type mismatches.

Changes

  • Added @attribute [CascadingTypeParameter(nameof(ItemType))] to GridView.razor and DataGrid.razor
  • Child columns now automatically infer ItemType from parent component
  • Updated sample pages and documentation to demonstrate simplified syntax

Impact

Before:

<GridView ItemType="Customer" AutoGenerateColumns="false">
  <Columns>
    <BoundField ItemType="Customer" DataField="Name" HeaderText="Name" />
    <BoundField ItemType="Customer" DataField="Email" HeaderText="Email" />
    <TemplateField ItemType="Customer" HeaderText="Actions">
      <ItemTemplate Context="Item">...</ItemTemplate>
    </TemplateField>
  </Columns>
</GridView>

After:

<GridView ItemType="Customer" AutoGenerateColumns="false">
  <Columns>
    <BoundField DataField="Name" HeaderText="Name" />
    <BoundField DataField="Email" HeaderText="Email" />
    <TemplateField HeaderText="Actions">
      <ItemTemplate Context="Item">...</ItemTemplate>
    </TemplateField>
  </Columns>
</GridView>

Fully backward compatible—explicit ItemType on columns continues to work.

Original prompt

This section details on the original issue you should resolve

<issue_title>Pass through ItemTypes to childcomponents</issue_title>
<issue_description>Example: For a GridView, need to pass the ItemType of the Grid through to the column child components so that we don't have to repeat the ItemType on each of the child components</issue_description>

<agent_instructions>I think we can do this with a cascading parameter type or something like that</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@csharpfritz Very interesting approach... I like the simplicity of the approach and re-use of other components we've already completed

Jeff

On Fri, Apr 17, 2020 at 3:45 AM Egil Hansen notifications@github.com
wrote:

I like the general idea of implementing the GridView through the ListView.
Users should not see a difference on the surface.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#163 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAATF4PFCAHELMMHXTXJNF3RNACK7ANCNFSM4MHWZITA
.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 31, 2026 14:12
…mType inference

Co-authored-by: csharpfritz <78577+csharpfritz@users.noreply.github.com>
Co-authored-by: csharpfritz <78577+csharpfritz@users.noreply.github.com>
Co-authored-by: csharpfritz <78577+csharpfritz@users.noreply.github.com>
Copilot AI changed the title [WIP] Pass through ItemTypes to child components Add CascadingTypeParameter for automatic ItemType inference in GridView/DataGrid columns Jan 31, 2026
Copilot AI requested a review from csharpfritz January 31, 2026 14:17
@csharpfritz csharpfritz marked this pull request as ready for review January 31, 2026 14:20
@csharpfritz csharpfritz merged commit ac59e5c into dev Jan 31, 2026
2 checks passed
@csharpfritz csharpfritz deleted the copilot/pass-itemtypes-to-children branch January 31, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass through ItemTypes to childcomponents

2 participants