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

the ItemChangedType doesn't pass correct value to it's EditTemplate #4721

Closed
1 task done
cairabbit opened this issue Nov 22, 2024 · 4 comments · Fixed by #4750
Closed
1 task done

the ItemChangedType doesn't pass correct value to it's EditTemplate #4721

cairabbit opened this issue Nov 22, 2024 · 4 comments · Fixed by #4750
Assignees
Labels
bug Something isn't working
Milestone

Comments

@cairabbit
Copy link
Collaborator

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm using Table to manage data with custom EditTemplate. My edit template component EditItemPanel has a field:

@typeparam TItem
@inject IStringLocalizer<EditItemPanel<TItem>> L

@code {
  [CascadingParameter]
  public ItemChangedType ChangedType { get; set; }
  [Parameter]
  [EditorRequired]
  public required TItem Model { get; set; }
  [Parameter]
  public string? NewTitle { get; set; }
  [Parameter]
  public string? EditTitle { get; set; }
  [Parameter]
  public RenderFragment<TItem>? NewItemTemplate { get; set; }
  [Parameter]
  [EditorRequired]
  public required RenderFragment<TItem> EditItemTemplate { get; set; }
}

<Panel>
  <Header>
    <div>
      @if (ChangedType == ItemChangedType.Add)
      {
        <h3>@(NewTitle ?? L.GetString("New Item"))</h3>
      }
      else
      {
        <h3>@(EditTitle ?? L.GetString("Edit Item"))</h3>
      }
    </div>
    <div class="flex-fill"></div>
    <div>
      <DialogCloseButton Icon="fa-solid fa-xmark" ButtonStyle="ButtonStyle.Round" Size="Size.Small" Text=""></DialogCloseButton>
    </div>
  </Header>
  <Body>
    <ValidateForm Model="@Model">
      @if (ChangedType == ItemChangedType.Add)
      {
        if (NewItemTemplate != null)
        {
          @NewItemTemplate(Model)
        }
        else
        {
          @EditItemTemplate(Model)
        }
      }
      else
      {
        @EditItemTemplate(Model)
      }
    </ValidateForm>
  </Body>
</Panel>

Then I use this compoent in table:

<Table TItem="AuthApp"
       IsPagination="true" PageItemsSource="@pageItemsSource" DataService="@dataService" CustomerSearchModel="filters"
       IsStriped="true" IsBordered="false" IsMultipleSelect="true"
       ShowToolbar="true" ShowSearch="true" ShowExtendButtons="true" ShowSkeleton="true" CollapsedTopSearch="true"
       ShowEmpty="true" SearchMode="SearchMode.Popup" SearchDialogSize="Size.Medium" EditMode="EditMode.Drawer"
       ShowAddButton="true" ShowExtendEditButtonCallback="@(o => true)" ShowExtendDeleteButtonCallback="@(o => true)">
  <TableColumns>
       ......
  </TableColumns>
  <CustomerSearchTemplate>
    .....
  </CustomerSearchTemplate>
  <EditTemplate>
    <EditItemPanel Model="@context" NewTitle="@L.GetString("New App")" EditTitle="@L.GetString("Edit App")">
      <EditItemTemplate Context="it">
        ......
      </EditItemTemplate>
    </EditItemPanel>
  </EditTemplate>
</Table>

When clicking on the extension button "edit" on each row, the ChangedType is always Add value.

Expected Behavior

Clicking on the "edit" button on each row, it should pass ItemChangedType.Update to the EditTemplate's child component.

Interactive render mode

Interactive Server (Interactive server-side rendering (interactive SSR) using Blazor Server)

Steps To Reproduce

see above description

Exceptions (if any)

No response

.NET Version

9.0

Anything else?

No response

@cairabbit cairabbit added the bug Something isn't working label Nov 22, 2024
Copy link

bb-auto bot commented Nov 22, 2024

@cairabbit Thank you for reporting. We will give triage later.

@bb-auto bb-auto bot added this to the v9.0.0 milestone Nov 22, 2024
@ArgoZhang
Copy link
Collaborator

@cairabbit could you submit a repro-project for this issue? thanks

@cairabbit
Copy link
Collaborator Author

Here is the repro-project: https://github.com/cairabbit/BlazorExample

bug.mp4

@ArgoZhang
Copy link
Collaborator

@cairabbit fix in the version 9.0.2-beta04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants