From 8f52842d570ae0d23885fae2c1d3a3cd1fe7f0b7 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 8 Feb 2025 23:52:54 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20OnClick=20?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs b/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs index 69848af544a..e695c04b6fa 100644 --- a/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs +++ b/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone +using Microsoft.AspNetCore.Components.Web; + namespace BootstrapBlazor.Components; /// @@ -102,6 +104,11 @@ public partial class Dropdown [Parameter] public bool ShowSplit { get; set; } + /// + /// 获得/设置 OnClick 事件 + /// + [Parameter] + public EventCallback OnClick { get; set; } /// /// 获得/设置 获取菜单对齐方式 默认 none 未设置 /// From 5f610662151a5ecdcd3ac8514507af657ec7b2c3 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 8 Feb 2025 23:53:11 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20OnClickWithout?= =?UTF-8?q?Render=20=E5=9B=9E=E8=B0=83=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs b/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs index e695c04b6fa..d2f4502fcd7 100644 --- a/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs +++ b/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs @@ -109,6 +109,13 @@ public partial class Dropdown /// [Parameter] public EventCallback OnClick { get; set; } + + /// + /// 获得/设置 OnClick 事件不刷新父组件 + /// + [Parameter] + public Func? OnClickWithoutRender { get; set; } + /// /// 获得/设置 获取菜单对齐方式 默认 none 未设置 /// From 91b4840b75d0d0d8626a60f84d82280799994906 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 8 Feb 2025 23:53:26 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E4=BA=8B=E4=BB=B6=E5=A7=94=E6=89=98=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Dropdown/Dropdown.razor.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs b/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs index d2f4502fcd7..bf9e226662d 100644 --- a/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs +++ b/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs @@ -217,4 +217,16 @@ protected async Task OnItemClick(SelectedItem item) } private string? ButtonText => IsFixedButtonText ? FixedButtonText : SelectedItem?.Text; + + private async Task OnClickButton() + { + if (OnClickWithoutRender != null) + { + await OnClickWithoutRender(); + } + if (OnClick.HasDelegate) + { + await OnClick.InvokeAsync(); + } + } } From a19e2cd6863abc6e927bf170cc2c92a8175a07cb Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 8 Feb 2025 23:53:45 +0800 Subject: [PATCH 4/6] =?UTF-8?q?feat:=20=E6=9B=B4=E6=94=B9=E4=B8=BA=20Dynam?= =?UTF-8?q?icElement=20=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Dropdown/Dropdown.razor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor b/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor index 26b69d56ad4..5df35546499 100644 --- a/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor +++ b/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor @@ -8,7 +8,8 @@ }
- + @if (ShowSplit) { From f9d99225925eb5f939aaeb028f8f5e0da0dc1b6c Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 8 Feb 2025 23:53:53 +0800 Subject: [PATCH 5/6] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor.Server/Components/Samples/Dropdowns.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor.Server/Components/Samples/Dropdowns.razor b/src/BootstrapBlazor.Server/Components/Samples/Dropdowns.razor index 71a55356052..9a564769028 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Dropdowns.razor +++ b/src/BootstrapBlazor.Server/Components/Samples/Dropdowns.razor @@ -37,7 +37,7 @@
- +
From c0610bebf2d837bdd36bdb3062213fdeafa8934b Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Sat, 8 Feb 2025 23:56:39 +0800 Subject: [PATCH 6/6] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/Dropdowns.razor.cs | 12 ++++++++++++ src/BootstrapBlazor.Server/Locales/en-US.json | 2 ++ src/BootstrapBlazor.Server/Locales/zh-CN.json | 2 ++ 3 files changed, 16 insertions(+) diff --git a/src/BootstrapBlazor.Server/Components/Samples/Dropdowns.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/Dropdowns.razor.cs index a47abc52468..5e51ff48194 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Dropdowns.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/Dropdowns.razor.cs @@ -251,6 +251,18 @@ private AttributeItem[] GetAttributes() => /// private EventItem[] GetEvents() => [ + new() + { + Name = "OnClick", + Description = Localizer["EventDesc1"], + Type ="EventCallback" + }, + new() + { + Name = "OnClickWithoutRender", + Description = Localizer["EventDesc2"], + Type ="Func" + }, new EventItem() { Name = "OnSelectedItemChanged", diff --git a/src/BootstrapBlazor.Server/Locales/en-US.json b/src/BootstrapBlazor.Server/Locales/en-US.json index 2f985a9ef14..43afeeb8947 100644 --- a/src/BootstrapBlazor.Server/Locales/en-US.json +++ b/src/BootstrapBlazor.Server/Locales/en-US.json @@ -1793,6 +1793,8 @@ "AttributeButtonTemplate": "The template of button", "AttributeItemTemplate": "The template of item", "AttributeItemsTemplate": "The template of items", + "EventDesc1": "This event is triggered when the button is clicked", + "EventDesc2": "This event is triggered when the button is clicked and the current component is not refreshed for performance improvement", "EventOnSelectedItemChanged": "Triggered when the value of the drop-down box changes", "FixedButtonText": "The text of fixed button", "Item1": "Melbourne", diff --git a/src/BootstrapBlazor.Server/Locales/zh-CN.json b/src/BootstrapBlazor.Server/Locales/zh-CN.json index 0f3fca089e3..a4e851896d0 100644 --- a/src/BootstrapBlazor.Server/Locales/zh-CN.json +++ b/src/BootstrapBlazor.Server/Locales/zh-CN.json @@ -1793,6 +1793,8 @@ "AttributeButtonTemplate": "按钮模板", "AttributeItemTemplate": "菜单项模板", "AttributeItemsTemplate": "下拉菜单模板", + "EventDesc1": "点击按钮时触发此事件", + "EventDesc2": "点击按钮时触发此事件并且不刷新当前组件,用于提高性能时使用", "EventOnSelectedItemChanged": "下拉框值发生改变时触发", "FixedButtonText": "固定按钮显示文字", "Item1": "北京",