mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-02 20:20:26 +08:00
!1712 fix(#I453H8): resolve set enabled to false not work in EditDialog
* doc: 格式化文档 * doc: 增加 EditDialog 弹窗示例 * fix: 修复 EditDialog 未判断 Enaable 参数问题
This commit is contained in:
parent
9be042d5cc
commit
936326b4c1
@ -7,13 +7,17 @@
|
|||||||
<p><code>EditDialog</code> 组件是 <code>Dialog</code> 组件的扩展,适用于数据弹出窗编辑。</p>
|
<p><code>EditDialog</code> 组件是 <code>Dialog</code> 组件的扩展,适用于数据弹出窗编辑。</p>
|
||||||
|
|
||||||
<Tips>
|
<Tips>
|
||||||
<p>通过调用注入服务 <code>DialogService</code> 的 <code>ShowEditDialog</code> 方法直接弹出编辑对话框,大大减少代码量。<code>EditDialogOption</code> 配置类继承 <code>DialogOption</code>,更多参数设置请点击 <a href="dialogs" target="_blank">[传送门]</a></p>
|
<p>通过调用注入服务 <code>DialogService</code> 的 <code>ShowEditDialog</code> 方法直接弹出编辑对话框,大大减少代码量。<code>EditDialogOption</code> 配置类继承 <code>DialogOption</code>,更多参数设置请点击 <a href="dialogs" target="_blank">[传送门]</a></p>
|
||||||
</Tips>
|
</Tips>
|
||||||
|
|
||||||
<Block Title="基础用法" Introduction="通过绑定 <code>TModel</code> 数据模型,自动生成模型各个字段的可编辑表单">
|
<Block Title="基础用法" Introduction="通过绑定 <code>TModel</code> 数据模型,自动生成模型各个字段的可编辑表单">
|
||||||
<Button Text="编辑弹窗(左对齐)" OnClickWithoutRender="@ShowDialog" />
|
<Button Text="编辑弹窗(左对齐)" OnClickWithoutRender="@ShowDialog" />
|
||||||
<Button Text="编辑弹窗(右对齐)" OnClickWithoutRender="@ShowAlignDialog" />
|
<Button Text="编辑弹窗(右对齐)" OnClickWithoutRender="@ShowAlignDialog" />
|
||||||
<Logger @ref="Trace" class="mt-3" />
|
<Logger @ref="Trace" class="mt-3" />
|
||||||
|
</Block>
|
||||||
|
|
||||||
|
<Block Title="设置绑定模型部分属性不显示" Introduction="通过设置 <code>IEditorItem</code> 实例的 <code>Editable=false</code>, 实现编辑弹窗不显示此属性">
|
||||||
|
<Button Text="弹窗" OnClickWithoutRender="@ShowEditDialog" />
|
||||||
</Block>
|
</Block>
|
||||||
|
|
||||||
<AttributeTable Items="@GetAttributes()" Title="EditDialogOption 属性" />
|
<AttributeTable Items="@GetAttributes()" Title="EditDialogOption 属性" />
|
||||||
|
@ -93,6 +93,40 @@ namespace BootstrapBlazor.Shared.Pages
|
|||||||
await DialogService.ShowEditDialog(option);
|
await DialogService.ShowEditDialog(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task ShowEditDialog()
|
||||||
|
{
|
||||||
|
var items = EditorItem<Foo>.GenerateEditorItems();
|
||||||
|
var item = items.First(i => i.GetFieldName() == nameof(Foo.Hobby));
|
||||||
|
item.Data = Foo.GenerateHobbys(Localizer);
|
||||||
|
|
||||||
|
// 设置 地址与数量 不可编辑
|
||||||
|
item = items.First(i => i.GetFieldName() == nameof(Foo.Address));
|
||||||
|
item.Editable = false;
|
||||||
|
item = items.First(i => i.GetFieldName() == nameof(Foo.Count));
|
||||||
|
item.Editable = false;
|
||||||
|
|
||||||
|
var option = new EditDialogOption<Foo>()
|
||||||
|
{
|
||||||
|
Title = "编辑对话框",
|
||||||
|
Model = Model,
|
||||||
|
Items = items,
|
||||||
|
ItemsPerRow = 2,
|
||||||
|
RowType = RowType.Inline,
|
||||||
|
OnCloseAsync = () =>
|
||||||
|
{
|
||||||
|
Trace.Log("关闭按钮被点击");
|
||||||
|
return Task.CompletedTask;
|
||||||
|
},
|
||||||
|
OnSaveAsync = context =>
|
||||||
|
{
|
||||||
|
Trace.Log("保存按钮被点击");
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
await DialogService.ShowEditDialog(option);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得属性方法
|
/// 获得属性方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -180,7 +180,7 @@ namespace BootstrapBlazor.Components
|
|||||||
if (CascadeEditorItems != null)
|
if (CascadeEditorItems != null)
|
||||||
{
|
{
|
||||||
// 通过级联参数渲染组件
|
// 通过级联参数渲染组件
|
||||||
FormItems.AddRange(CascadeEditorItems);
|
FormItems.AddRange(CascadeEditorItems.Where(i => i.Editable));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user