Update grid popup headers and edit form logic
CatalogsGrid now sets popup edit form header dynamically ("Neu" for new, "Edit" for existing) and only shows the "Update-Prozedur" field when editing. Added IsNew property to CatalogEditModel. MassDataGrid sets popup header to "Bearbeiten". Also standardized DateChanged event handler style in both components.
This commit is contained in:
@@ -78,6 +78,7 @@ else
|
|||||||
CssClass="mb-4 catalog-grid"
|
CssClass="mb-4 catalog-grid"
|
||||||
EditMode="GridEditMode.PopupEditForm"
|
EditMode="GridEditMode.PopupEditForm"
|
||||||
PopupEditFormCssClass="catalog-edit-popup"
|
PopupEditFormCssClass="catalog-edit-popup"
|
||||||
|
PopupEditFormHeaderText="@popupHeaderText"
|
||||||
CustomizeEditModel="OnCustomizeEditModel"
|
CustomizeEditModel="OnCustomizeEditModel"
|
||||||
EditModelSaving="OnEditModelSaving"
|
EditModelSaving="OnEditModelSaving"
|
||||||
DataItemDeleting="OnDataItemDeleting">
|
DataItemDeleting="OnDataItemDeleting">
|
||||||
@@ -114,7 +115,7 @@ else
|
|||||||
<DxGridDataColumn FieldName="@nameof(CatalogReadDto.AddedWhen)" Caption="Angelegt am" ReadOnly="true">
|
<DxGridDataColumn FieldName="@nameof(CatalogReadDto.AddedWhen)" Caption="Angelegt am" ReadOnly="true">
|
||||||
<FilterRowCellTemplate Context="filter">
|
<FilterRowCellTemplate Context="filter">
|
||||||
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
||||||
DateChanged="@((DateTime? value) => filter.FilterRowValue = value)"
|
DateChanged="@((DateTime? value) => { filter.FilterRowValue = value; })"
|
||||||
Width="100%" />
|
Width="100%" />
|
||||||
</FilterRowCellTemplate>
|
</FilterRowCellTemplate>
|
||||||
</DxGridDataColumn>
|
</DxGridDataColumn>
|
||||||
@@ -128,13 +129,13 @@ else
|
|||||||
<DxGridDataColumn FieldName="@nameof(CatalogReadDto.ChangedWhen)" Caption="Geändert am" ReadOnly="true">
|
<DxGridDataColumn FieldName="@nameof(CatalogReadDto.ChangedWhen)" Caption="Geändert am" ReadOnly="true">
|
||||||
<FilterRowCellTemplate Context="filter">
|
<FilterRowCellTemplate Context="filter">
|
||||||
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
||||||
DateChanged="@((DateTime? value) => filter.FilterRowValue = value)"
|
DateChanged="@((DateTime? value) => { filter.FilterRowValue = value; })"
|
||||||
Width="100%" />
|
Width="100%" />
|
||||||
</FilterRowCellTemplate>
|
</FilterRowCellTemplate>
|
||||||
</DxGridDataColumn>
|
</DxGridDataColumn>
|
||||||
</Columns>
|
</Columns>
|
||||||
<EditFormTemplate Context="editFormContext">
|
<EditFormTemplate Context="editFormContext">
|
||||||
@{ SetEditContext(editFormContext.EditContext); var editModel = (CatalogEditModel)editFormContext.EditModel; }
|
@{ SetEditContext(editFormContext.EditContext); var editModel = (CatalogEditModel)editFormContext.EditModel; SetPopupHeaderText(editModel.IsNew); }
|
||||||
<DxFormLayout ColCount="2">
|
<DxFormLayout ColCount="2">
|
||||||
<DxFormLayoutItem Caption="Titel">
|
<DxFormLayoutItem Caption="Titel">
|
||||||
<DxTextBox @bind-Text="editModel.CatTitle"
|
<DxTextBox @bind-Text="editModel.CatTitle"
|
||||||
@@ -145,15 +146,18 @@ else
|
|||||||
<DxFormLayoutItem Caption="Kennung">
|
<DxFormLayoutItem Caption="Kennung">
|
||||||
<DxTextBox @bind-Text="editModel.CatString" Width="100%" />
|
<DxTextBox @bind-Text="editModel.CatString" Width="100%" />
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
<DxFormLayoutItem Caption="Update-Prozedur">
|
@if (!editModel.IsNew)
|
||||||
<DxComboBox Data="@procedureOptions"
|
{
|
||||||
TData="ProcedureOption"
|
<DxFormLayoutItem Caption="Update-Prozedur">
|
||||||
TValue="int"
|
<DxComboBox Data="@procedureOptions"
|
||||||
TextFieldName="Text"
|
TData="ProcedureOption"
|
||||||
ValueFieldName="Value"
|
TValue="int"
|
||||||
@bind-Value="editModel.UpdateProcedure"
|
TextFieldName="Text"
|
||||||
Width="100%" />
|
ValueFieldName="Value"
|
||||||
</DxFormLayoutItem>
|
@bind-Value="editModel.UpdateProcedure"
|
||||||
|
Width="100%" />
|
||||||
|
</DxFormLayoutItem>
|
||||||
|
}
|
||||||
<DxFormLayoutItem ColSpanMd="12">
|
<DxFormLayoutItem ColSpanMd="12">
|
||||||
<ValidationSummary />
|
<ValidationSummary />
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
@@ -170,6 +174,7 @@ else
|
|||||||
private string? infoMessage;
|
private string? infoMessage;
|
||||||
private EditContext? editContext;
|
private EditContext? editContext;
|
||||||
private ValidationMessageStore? validationMessageStore;
|
private ValidationMessageStore? validationMessageStore;
|
||||||
|
private string popupHeaderText = "Edit";
|
||||||
|
|
||||||
private readonly List<ProcedureOption> procedureOptions = new()
|
private readonly List<ProcedureOption> procedureOptions = new()
|
||||||
{
|
{
|
||||||
@@ -227,9 +232,10 @@ else
|
|||||||
|
|
||||||
private void OnCustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
private void OnCustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||||
{
|
{
|
||||||
|
popupHeaderText = e.IsNew ? "Neu" : "Edit";
|
||||||
if (e.IsNew)
|
if (e.IsNew)
|
||||||
{
|
{
|
||||||
e.EditModel = new CatalogEditModel();
|
e.EditModel = new CatalogEditModel { IsNew = true };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +246,8 @@ else
|
|||||||
CatTitle = item.CatTitle,
|
CatTitle = item.CatTitle,
|
||||||
CatString = item.CatString,
|
CatString = item.CatString,
|
||||||
UpdateProcedure = 0,
|
UpdateProcedure = 0,
|
||||||
OriginalCatTitle = item.CatTitle
|
OriginalCatTitle = item.CatTitle,
|
||||||
|
IsNew = false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,6 +392,11 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetPopupHeaderText(bool isNew)
|
||||||
|
{
|
||||||
|
popupHeaderText = isNew ? "Neu" : "Edit";
|
||||||
|
}
|
||||||
|
|
||||||
private sealed class CatalogEditModel
|
private sealed class CatalogEditModel
|
||||||
{
|
{
|
||||||
public int Guid { get; set; }
|
public int Guid { get; set; }
|
||||||
@@ -392,6 +404,7 @@ else
|
|||||||
public string CatString { get; set; } = string.Empty;
|
public string CatString { get; set; } = string.Empty;
|
||||||
public int UpdateProcedure { get; set; }
|
public int UpdateProcedure { get; set; }
|
||||||
public string OriginalCatTitle { get; set; } = string.Empty;
|
public string OriginalCatTitle { get; set; } = string.Empty;
|
||||||
|
public bool IsNew { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class ProcedureOption
|
private sealed class ProcedureOption
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ else
|
|||||||
PageSize="100"
|
PageSize="100"
|
||||||
CssClass="mb-3 massdata-grid"
|
CssClass="mb-3 massdata-grid"
|
||||||
EditMode="GridEditMode.PopupEditForm"
|
EditMode="GridEditMode.PopupEditForm"
|
||||||
|
PopupEditFormHeaderText="Bearbeiten"
|
||||||
EditModelSaving="OnEditModelSaving"
|
EditModelSaving="OnEditModelSaving"
|
||||||
DataItemDeleting="OnDataItemDeleting">
|
DataItemDeleting="OnDataItemDeleting">
|
||||||
<Columns>
|
<Columns>
|
||||||
@@ -129,14 +130,14 @@ else
|
|||||||
<DxGridDataColumn FieldName="@nameof(MassDataReadDto.AddedWhen)" Caption="Added" ReadOnly="true">
|
<DxGridDataColumn FieldName="@nameof(MassDataReadDto.AddedWhen)" Caption="Added" ReadOnly="true">
|
||||||
<FilterRowCellTemplate Context="filter">
|
<FilterRowCellTemplate Context="filter">
|
||||||
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
||||||
DateChanged="@((DateTime? value) => filter.FilterRowValue = value)"
|
DateChanged="@((DateTime? value) => { filter.FilterRowValue = value; })"
|
||||||
Width="100%" />
|
Width="100%" />
|
||||||
</FilterRowCellTemplate>
|
</FilterRowCellTemplate>
|
||||||
</DxGridDataColumn>
|
</DxGridDataColumn>
|
||||||
<DxGridDataColumn FieldName="@nameof(MassDataReadDto.ChangedWhen)" Caption="Changed" ReadOnly="true">
|
<DxGridDataColumn FieldName="@nameof(MassDataReadDto.ChangedWhen)" Caption="Changed" ReadOnly="true">
|
||||||
<FilterRowCellTemplate Context="filter">
|
<FilterRowCellTemplate Context="filter">
|
||||||
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
||||||
DateChanged="@((DateTime? value) => filter.FilterRowValue = value)"
|
DateChanged="@((DateTime? value) => { filter.FilterRowValue = value; })"
|
||||||
Width="100%" />
|
Width="100%" />
|
||||||
</FilterRowCellTemplate>
|
</FilterRowCellTemplate>
|
||||||
</DxGridDataColumn>
|
</DxGridDataColumn>
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ else
|
|||||||
CssClass="mb-4 catalog-grid"
|
CssClass="mb-4 catalog-grid"
|
||||||
EditMode="GridEditMode.PopupEditForm"
|
EditMode="GridEditMode.PopupEditForm"
|
||||||
PopupEditFormCssClass="catalog-edit-popup"
|
PopupEditFormCssClass="catalog-edit-popup"
|
||||||
|
PopupEditFormHeaderText="@popupHeaderText"
|
||||||
CustomizeEditModel="OnCustomizeEditModel"
|
CustomizeEditModel="OnCustomizeEditModel"
|
||||||
EditModelSaving="OnEditModelSaving"
|
EditModelSaving="OnEditModelSaving"
|
||||||
DataItemDeleting="OnDataItemDeleting">
|
DataItemDeleting="OnDataItemDeleting">
|
||||||
@@ -73,7 +74,7 @@ else
|
|||||||
<DxGridDataColumn FieldName="@nameof(CatalogReadDto.AddedWhen)" Caption="Angelegt am" ReadOnly="true">
|
<DxGridDataColumn FieldName="@nameof(CatalogReadDto.AddedWhen)" Caption="Angelegt am" ReadOnly="true">
|
||||||
<FilterRowCellTemplate Context="filter">
|
<FilterRowCellTemplate Context="filter">
|
||||||
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
||||||
DateChanged="@((DateTime? value) => filter.FilterRowValue = value)"
|
DateChanged="@((DateTime? value) => { filter.FilterRowValue = value; })"
|
||||||
Width="100%" />
|
Width="100%" />
|
||||||
</FilterRowCellTemplate>
|
</FilterRowCellTemplate>
|
||||||
</DxGridDataColumn>
|
</DxGridDataColumn>
|
||||||
@@ -87,13 +88,13 @@ else
|
|||||||
<DxGridDataColumn FieldName="@nameof(CatalogReadDto.ChangedWhen)" Caption="Geändert am" ReadOnly="true">
|
<DxGridDataColumn FieldName="@nameof(CatalogReadDto.ChangedWhen)" Caption="Geändert am" ReadOnly="true">
|
||||||
<FilterRowCellTemplate Context="filter">
|
<FilterRowCellTemplate Context="filter">
|
||||||
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
||||||
DateChanged="@((DateTime? value) => filter.FilterRowValue = value)"
|
DateChanged="@((DateTime? value) => { filter.FilterRowValue = value; })"
|
||||||
Width="100%" />
|
Width="100%" />
|
||||||
</FilterRowCellTemplate>
|
</FilterRowCellTemplate>
|
||||||
</DxGridDataColumn>
|
</DxGridDataColumn>
|
||||||
</Columns>
|
</Columns>
|
||||||
<EditFormTemplate Context="editFormContext">
|
<EditFormTemplate Context="editFormContext">
|
||||||
@{ SetEditContext(editFormContext.EditContext); var editModel = (CatalogEditModel)editFormContext.EditModel; }
|
@{ SetEditContext(editFormContext.EditContext); var editModel = (CatalogEditModel)editFormContext.EditModel; SetPopupHeaderText(editModel.IsNew); }
|
||||||
<DxFormLayout ColCount="2">
|
<DxFormLayout ColCount="2">
|
||||||
<DxFormLayoutItem Caption="Titel">
|
<DxFormLayoutItem Caption="Titel">
|
||||||
<DxTextBox @bind-Text="editModel.CatTitle"
|
<DxTextBox @bind-Text="editModel.CatTitle"
|
||||||
@@ -104,15 +105,18 @@ else
|
|||||||
<DxFormLayoutItem Caption="Kennung">
|
<DxFormLayoutItem Caption="Kennung">
|
||||||
<DxTextBox @bind-Text="editModel.CatString" Width="100%" />
|
<DxTextBox @bind-Text="editModel.CatString" Width="100%" />
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
<DxFormLayoutItem Caption="Update-Prozedur">
|
@if (!editModel.IsNew)
|
||||||
<DxComboBox Data="@procedureOptions"
|
{
|
||||||
TData="ProcedureOption"
|
<DxFormLayoutItem Caption="Update-Prozedur">
|
||||||
TValue="int"
|
<DxComboBox Data="@procedureOptions"
|
||||||
TextFieldName="Text"
|
TData="ProcedureOption"
|
||||||
ValueFieldName="Value"
|
TValue="int"
|
||||||
@bind-Value="editModel.UpdateProcedure"
|
TextFieldName="Text"
|
||||||
Width="100%" />
|
ValueFieldName="Value"
|
||||||
</DxFormLayoutItem>
|
@bind-Value="editModel.UpdateProcedure"
|
||||||
|
Width="100%" />
|
||||||
|
</DxFormLayoutItem>
|
||||||
|
}
|
||||||
<DxFormLayoutItem ColSpanMd="12">
|
<DxFormLayoutItem ColSpanMd="12">
|
||||||
<ValidationSummary />
|
<ValidationSummary />
|
||||||
</DxFormLayoutItem>
|
</DxFormLayoutItem>
|
||||||
@@ -129,6 +133,7 @@ else
|
|||||||
private string? infoMessage;
|
private string? infoMessage;
|
||||||
private EditContext? editContext;
|
private EditContext? editContext;
|
||||||
private ValidationMessageStore? validationMessageStore;
|
private ValidationMessageStore? validationMessageStore;
|
||||||
|
private string popupHeaderText = "Edit";
|
||||||
|
|
||||||
private readonly List<ProcedureOption> procedureOptions = new()
|
private readonly List<ProcedureOption> procedureOptions = new()
|
||||||
{
|
{
|
||||||
@@ -184,11 +189,17 @@ else
|
|||||||
editContext.NotifyValidationStateChanged();
|
editContext.NotifyValidationStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetPopupHeaderText(bool isNew)
|
||||||
|
{
|
||||||
|
popupHeaderText = isNew ? "Neu" : "Edit";
|
||||||
|
}
|
||||||
|
|
||||||
private void OnCustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
private void OnCustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||||
{
|
{
|
||||||
|
popupHeaderText = e.IsNew ? "Neu" : "Edit";
|
||||||
if (e.IsNew)
|
if (e.IsNew)
|
||||||
{
|
{
|
||||||
e.EditModel = new CatalogEditModel();
|
e.EditModel = new CatalogEditModel { IsNew = true };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +210,8 @@ else
|
|||||||
CatTitle = item.CatTitle,
|
CatTitle = item.CatTitle,
|
||||||
CatString = item.CatString,
|
CatString = item.CatString,
|
||||||
UpdateProcedure = 0,
|
UpdateProcedure = 0,
|
||||||
OriginalCatTitle = item.CatTitle
|
OriginalCatTitle = item.CatTitle,
|
||||||
|
IsNew = false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,6 +363,7 @@ else
|
|||||||
public string CatString { get; set; } = string.Empty;
|
public string CatString { get; set; } = string.Empty;
|
||||||
public int UpdateProcedure { get; set; }
|
public int UpdateProcedure { get; set; }
|
||||||
public string OriginalCatTitle { get; set; } = string.Empty;
|
public string OriginalCatTitle { get; set; } = string.Empty;
|
||||||
|
public bool IsNew { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class ProcedureOption
|
private sealed class ProcedureOption
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ else
|
|||||||
PageSize="100"
|
PageSize="100"
|
||||||
CssClass="mb-3 massdata-grid"
|
CssClass="mb-3 massdata-grid"
|
||||||
EditMode="GridEditMode.PopupEditForm"
|
EditMode="GridEditMode.PopupEditForm"
|
||||||
|
PopupEditFormHeaderText="Bearbeiten"
|
||||||
EditModelSaving="OnEditModelSaving"
|
EditModelSaving="OnEditModelSaving"
|
||||||
DataItemDeleting="OnDataItemDeleting">
|
DataItemDeleting="OnDataItemDeleting">
|
||||||
<Columns>
|
<Columns>
|
||||||
@@ -129,14 +130,14 @@ else
|
|||||||
<DxGridDataColumn FieldName="@nameof(MassDataReadDto.AddedWhen)" Caption="Added" ReadOnly="true">
|
<DxGridDataColumn FieldName="@nameof(MassDataReadDto.AddedWhen)" Caption="Added" ReadOnly="true">
|
||||||
<FilterRowCellTemplate Context="filter">
|
<FilterRowCellTemplate Context="filter">
|
||||||
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
||||||
DateChanged="@((DateTime? value) => filter.FilterRowValue = value)"
|
DateChanged="@((DateTime? value) => { filter.FilterRowValue = value; })"
|
||||||
Width="100%" />
|
Width="100%" />
|
||||||
</FilterRowCellTemplate>
|
</FilterRowCellTemplate>
|
||||||
</DxGridDataColumn>
|
</DxGridDataColumn>
|
||||||
<DxGridDataColumn FieldName="@nameof(MassDataReadDto.ChangedWhen)" Caption="Changed" ReadOnly="true">
|
<DxGridDataColumn FieldName="@nameof(MassDataReadDto.ChangedWhen)" Caption="Changed" ReadOnly="true">
|
||||||
<FilterRowCellTemplate Context="filter">
|
<FilterRowCellTemplate Context="filter">
|
||||||
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
<DxDateEdit Date="@((DateTime?)filter.FilterRowValue)"
|
||||||
DateChanged="@((DateTime? value) => filter.FilterRowValue = value)"
|
DateChanged="@((DateTime? value) => { filter.FilterRowValue = value; })"
|
||||||
Width="100%" />
|
Width="100%" />
|
||||||
</FilterRowCellTemplate>
|
</FilterRowCellTemplate>
|
||||||
</DxGridDataColumn>
|
</DxGridDataColumn>
|
||||||
|
|||||||
Reference in New Issue
Block a user