From 2bc5d8442c24824f45289bcb24b5fbe97296a444 Mon Sep 17 00:00:00 2001 From: Argo-Cloud Date: Wed, 24 Mar 2021 01:12:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20IEditorItem=20=E5=A2=9E=E5=8A=A0=20?= =?UTF-8?q?ComponentType=20=E5=B1=9E=E6=80=A7=E5=8F=AF=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=91=88=E7=8E=B0=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Attributes/AutoGenerateColumnAttribute.cs | 5 +++++ src/BootstrapBlazor/Components/EditorForm/EditorItem.cs | 6 ++++++ src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs | 7 ++++++- .../Components/Table/InternalTableColumn.cs | 5 +++++ src/BootstrapBlazor/Components/Table/TableColumn.cs | 8 +++++++- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs b/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs index c632fd6e0..c5145e5c9 100644 --- a/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs +++ b/src/BootstrapBlazor/Attributes/AutoGenerateColumnAttribute.cs @@ -90,6 +90,11 @@ namespace BootstrapBlazor.Components /// public RenderFragment? EditTemplate { get; set; } + /// + /// 获得/设置 组件类型 默认为 null + /// + public Type? ComponentType { get; set; } + /// /// 获得/设置 显示模板 /// diff --git a/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs b/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs index 35ea379f0..b5e75eb9c 100644 --- a/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs +++ b/src/BootstrapBlazor/Components/EditorForm/EditorItem.cs @@ -77,6 +77,12 @@ namespace BootstrapBlazor.Components [Parameter] public RenderFragment? EditTemplate { get; set; } + /// + /// 获得/设置 组件类型 默认为 null + /// + [Parameter] + public Type? ComponentType { get; set; } + /// /// 获得/设置 显示顺序 /// diff --git a/src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs b/src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs index 5f536df63..3eab07172 100644 --- a/src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs +++ b/src/BootstrapBlazor/Components/EditorForm/IEditorItem.cs @@ -43,7 +43,7 @@ namespace BootstrapBlazor.Components /// object? Step { get; set; } - /// + /// /// 获得/设置 Textarea 行数 默认为 0 /// int Rows { get; set; } @@ -53,6 +53,11 @@ namespace BootstrapBlazor.Components /// RenderFragment? EditTemplate { get; set; } + /// + /// 获得/设置 组件类型 默认为 null + /// + Type? ComponentType { get; set; } + /// /// 获取绑定字段显示名称方法 /// diff --git a/src/BootstrapBlazor/Components/Table/InternalTableColumn.cs b/src/BootstrapBlazor/Components/Table/InternalTableColumn.cs index e71e67b26..742c22a94 100644 --- a/src/BootstrapBlazor/Components/Table/InternalTableColumn.cs +++ b/src/BootstrapBlazor/Components/Table/InternalTableColumn.cs @@ -71,6 +71,11 @@ namespace BootstrapBlazor.Components public RenderFragment? EditTemplate { get; set; } + /// + /// 获得/设置 组件类型 默认为 null + /// + public Type? ComponentType { get; set; } + /// /// 获得/设置 额外数据源一般用于下拉框或者 CheckboxList 这种需要额外配置数据源组件使用 /// diff --git a/src/BootstrapBlazor/Components/Table/TableColumn.cs b/src/BootstrapBlazor/Components/Table/TableColumn.cs index c84eb1139..a0e57b91b 100644 --- a/src/BootstrapBlazor/Components/Table/TableColumn.cs +++ b/src/BootstrapBlazor/Components/Table/TableColumn.cs @@ -25,6 +25,12 @@ namespace BootstrapBlazor.Components /// public IFilter? Filter { get; set; } + /// + /// 获得/设置 组件类型 默认为 null + /// + [Parameter] + public Type? ComponentType { get; set; } + /// /// 获得/设置 绑定列类型 /// @@ -254,6 +260,6 @@ namespace BootstrapBlazor.Components /// public string GetFieldName() => _fieldIdentifier?.FieldName ?? ""; - private static readonly ConcurrentDictionary<(Type ModelType, string FieldName), Func> GetPropertyCache = new ConcurrentDictionary<(Type, string), Func>(); + private static readonly ConcurrentDictionary<(Type ModelType, string FieldName), Func> GetPropertyCache = new(); } } -- Gitee From d6f1564c9d541956840e964f8af7fc5c0eca6c20 Mon Sep 17 00:00:00 2001 From: Argo-Cloud Date: Wed, 24 Mar 2021 01:13:25 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E7=BB=84=E4=BB=B6=E5=86=85?= =?UTF-8?q?=E9=83=A8=E5=A4=84=E7=90=86=20bool=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=91=88=E7=8E=B0=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/EditorForm/EditorForm.razor.cs | 2 +- src/BootstrapBlazor/Components/Table/Table.razor.cs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs b/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs index f039e5067..16574c2d1 100644 --- a/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs +++ b/src/BootstrapBlazor/Components/EditorForm/EditorForm.razor.cs @@ -212,7 +212,7 @@ namespace BootstrapBlazor.Components var tDelegate = typeof(Func<>).MakeGenericType(fieldType); var valueExpression = Expression.Lambda(tDelegate, body); - var componentType = EditorForm.GenerateComponent(fieldType, item.Rows != 0); + var componentType = item.ComponentType ?? EditorForm.GenerateComponent(fieldType, item.Rows != 0); builder.OpenComponent(0, componentType); builder.AddAttribute(1, "DisplayText", displayName); builder.AddAttribute(2, "Value", fieldValue); diff --git a/src/BootstrapBlazor/Components/Table/Table.razor.cs b/src/BootstrapBlazor/Components/Table/Table.razor.cs index 7e5038226..39cf4426c 100644 --- a/src/BootstrapBlazor/Components/Table/Table.razor.cs +++ b/src/BootstrapBlazor/Components/Table/Table.razor.cs @@ -610,6 +610,16 @@ namespace BootstrapBlazor.Components { var content = ""; var val = Table.GetItemValue(col.GetFieldName(), item); + + // 自动化处理 bool 值 + if (val is bool && col.ComponentType != null) + { + builder.OpenComponent(0, col.ComponentType); + builder.AddAttribute(1, "Value", val); + builder.AddAttribute(2, "IsDisabled", true); + builder.CloseComponent(); + return; + } if (col.Formatter != null) { // 格式化回调委托 -- Gitee From d7aa19fb970477a0b02cdd7e51878e3e59bafc5b Mon Sep 17 00:00:00 2001 From: Argo-Cloud Date: Wed, 24 Mar 2021 01:14:44 +0800 Subject: [PATCH 3/3] =?UTF-8?q?docs:=20=E7=A7=BB=E9=99=A4=E5=B8=83?= =?UTF-8?q?=E5=B0=94=E7=B1=BB=E5=9E=8B=E6=95=B0=E6=8D=AE=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/DataDialogComponent.razor | 7 --- .../Pages/Components/Foo.cs | 2 +- .../Pages/Samples/EditorForms.razor | 7 --- .../Samples/Table/TablesAutoRefresh.razor | 6 +- .../Pages/Samples/Table/TablesColumn.razor | 13 +--- .../Pages/Samples/Table/TablesDetailRow.razor | 18 +----- .../Samples/Table/TablesDetailRow.razor.cs | 11 ++-- .../Pages/Samples/Table/TablesEdit.razor | 61 +++---------------- .../Samples/Table/TablesFixedColumn.razor | 24 ++------ .../Pages/Samples/Table/TablesWrap.razor | 6 +- 10 files changed, 24 insertions(+), 131 deletions(-) diff --git a/src/BootstrapBlazor.Shared/Pages/Components/DataDialogComponent.razor b/src/BootstrapBlazor.Shared/Pages/Components/DataDialogComponent.razor index 8d412a422..e48331bf9 100644 --- a/src/BootstrapBlazor.Shared/Pages/Components/DataDialogComponent.razor +++ b/src/BootstrapBlazor.Shared/Pages/Components/DataDialogComponent.razor @@ -12,13 +12,6 @@ - - -
- -
-
-
diff --git a/src/BootstrapBlazor.Shared/Pages/Components/Foo.cs b/src/BootstrapBlazor.Shared/Pages/Components/Foo.cs index b2a8d0988..8f2de63f8 100644 --- a/src/BootstrapBlazor.Shared/Pages/Components/Foo.cs +++ b/src/BootstrapBlazor.Shared/Pages/Components/Foo.cs @@ -61,7 +61,7 @@ namespace BootstrapBlazor.Shared.Pages.Components /// /// [Display(Name = "是/否")] - [AutoGenerateColumn(Order = 50)] + [AutoGenerateColumn(Order = 50, ComponentType = typeof(Switch))] public bool Complete { get; set; } /// diff --git a/src/BootstrapBlazor.Shared/Pages/Samples/EditorForms.razor b/src/BootstrapBlazor.Shared/Pages/Samples/EditorForms.razor index a14e41a88..bb953574f 100644 --- a/src/BootstrapBlazor.Shared/Pages/Samples/EditorForms.razor +++ b/src/BootstrapBlazor.Shared/Pages/Samples/EditorForms.razor @@ -56,13 +56,6 @@ - - -
- -
-
-