File tree Expand file tree Collapse file tree 6 files changed +46
-3
lines changed
BootstrapBlazor/Components/Dropdown Expand file tree Collapse file tree 6 files changed +46
-3
lines changed Original file line number Diff line number Diff line change 3737 <Dropdown TValue =" string" Items =" Items" ShowSplit =" true" Color =" Color.Primary" ></Dropdown >
3838 </div >
3939 <div class =" col-6 col-sm-4 col-md-3" >
40- <Dropdown TValue =" string" Items =" Items" ShowSplit =" false " Color =" Color.Info" ></Dropdown >
40+ <Dropdown TValue =" string" Items =" Items" ShowSplit =" true " Color =" Color.Info" ></Dropdown >
4141 </div >
4242 <div class =" col-6 col-sm-4 col-md-3" >
4343 <Dropdown TValue =" string" Items =" Items" ShowSplit =" true" Color =" Color.Warning" ></Dropdown >
Original file line number Diff line number Diff line change @@ -251,6 +251,18 @@ private AttributeItem[] GetAttributes() =>
251251 /// <returns></returns>
252252 private EventItem [ ] GetEvents ( ) =>
253253 [
254+ new ( )
255+ {
256+ Name = "OnClick" ,
257+ Description = Localizer [ "EventDesc1" ] ,
258+ Type = "EventCallback<MouseEventArgs>"
259+ } ,
260+ new ( )
261+ {
262+ Name = "OnClickWithoutRender" ,
263+ Description = Localizer [ "EventDesc2" ] ,
264+ Type = "Func<Task>"
265+ } ,
254266 new EventItem ( )
255267 {
256268 Name = "OnSelectedItemChanged" ,
Original file line number Diff line number Diff line change 17931793 "AttributeButtonTemplate": "The template of button",
17941794 "AttributeItemTemplate": "The template of item",
17951795 "AttributeItemsTemplate": "The template of items",
1796+ "EventDesc1": "This event is triggered when the button is clicked",
1797+ "EventDesc2": "This event is triggered when the button is clicked and the current component is not refreshed for performance improvement",
17961798 "EventOnSelectedItemChanged": "Triggered when the value of the drop-down box changes",
17971799 "FixedButtonText": "The text of fixed button",
17981800 "Item1": "Melbourne",
Original file line number Diff line number Diff line change 17931793 "AttributeButtonTemplate" : " 按钮模板" ,
17941794 "AttributeItemTemplate" : " 菜单项模板" ,
17951795 "AttributeItemsTemplate" : " 下拉菜单模板" ,
1796+ "EventDesc1" : " 点击按钮时触发此事件" ,
1797+ "EventDesc2" : " 点击按钮时触发此事件并且不刷新当前组件,用于提高性能时使用" ,
17961798 "EventOnSelectedItemChanged" : " 下拉框值发生改变时触发" ,
17971799 "FixedButtonText" : " 固定按钮显示文字" ,
17981800 "Item1" : " 北京" ,
Original file line number Diff line number Diff line change 88 <BootstrapLabel for =" @Id" ShowLabelTooltip =" ShowLabelTooltip" Value =" @DisplayText" />
99}
1010<div @attributes =" @AdditionalAttributes" id =" @Id" class =" @DirectionClassName" >
11- <button type =" button" class =" @ButtonClassName" data-bs-toggle =" @DropdownToggle" disabled =" @Disabled" >
11+ <DynamicElement type =" button" class =" @ButtonClassName" data-bs-toggle =" @DropdownToggle" disabled =" @Disabled"
12+ TriggerClick =" ShowSplit" OnClick =" OnClickButton" >
1213 @if (ButtonTemplate == null )
1314 {
1415 @ButtonText
1718 {
1819 @ButtonTemplate(SelectedItem)
1920 }
20- </button >
21+ </DynamicElement >
2122 @if (ShowSplit )
2223 {
2324 <button type =" button" class =" @ClassName" data-bs-toggle =" @ToggleString" disabled =" @Disabled" aria-haspopup =" true" aria-expanded =" false" ></button >
Original file line number Diff line number Diff line change 33// See the LICENSE file in the project root for more information.
44// Maintainer: Argo Zhang([email protected] ) Website: https://www.blazor.zone 55
6+ using Microsoft . AspNetCore . Components . Web ;
7+
68namespace BootstrapBlazor . Components ;
79
810/// <summary>
@@ -102,6 +104,18 @@ public partial class Dropdown<TValue>
102104 [ Parameter ]
103105 public bool ShowSplit { get ; set ; }
104106
107+ /// <summary>
108+ /// 获得/设置 OnClick 事件
109+ /// </summary>
110+ [ Parameter ]
111+ public EventCallback < MouseEventArgs > OnClick { get ; set ; }
112+
113+ /// <summary>
114+ /// 获得/设置 OnClick 事件不刷新父组件
115+ /// </summary>
116+ [ Parameter ]
117+ public Func < Task > ? OnClickWithoutRender { get ; set ; }
118+
105119 /// <summary>
106120 /// 获得/设置 获取菜单对齐方式 默认 none 未设置
107121 /// </summary>
@@ -203,4 +217,16 @@ protected async Task OnItemClick(SelectedItem item)
203217 }
204218
205219 private string ? ButtonText => IsFixedButtonText ? FixedButtonText : SelectedItem ? . Text ;
220+
221+ private async Task OnClickButton ( )
222+ {
223+ if ( OnClickWithoutRender != null )
224+ {
225+ await OnClickWithoutRender ( ) ;
226+ }
227+ if ( OnClick . HasDelegate )
228+ {
229+ await OnClick . InvokeAsync ( ) ;
230+ }
231+ }
206232}
You can’t perform that action at this time.
0 commit comments