Skip to content

Commit 3d46f4e

Browse files
docs(ContextMenu): add TreeView sample code (#5118)
* docs(ContextMenus): 补充右键菜单文档 * chore: bump version 9.2.8-beta04 * chore: bump version 9.2.8-beta03 --------- Co-authored-by: Argo Zhang <[email protected]>
1 parent d17ea0d commit 3d46f4e

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

src/BootstrapBlazor.Server/Components/Samples/ContextMenus.razor

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,15 @@
5858
<ContextMenuZone>
5959
<TreeView TItem="TreeFoo" Items="@TreeItems" />
6060
<ContextMenu OnBeforeShowCallback="OnBeforeShowCallback">
61-
<ContextMenuItem Icon="fa-solid fa-copy" Text="@Localizer["ContextMenuItemCopy"]" OnClick="OnCopy"></ContextMenuItem>
62-
<ContextMenuItem Icon="fa-solid fa-paste" Text="@Localizer["ContextMenuItemPast"]" OnClick="OnPaste"></ContextMenuItem>
61+
@if (SelectModel?.Id == "1020")
62+
{
63+
<ContextMenuItem Icon="fa-solid fa-copy" Text="@Localizer["ContextMenuItemCopy"]" OnClick="OnCopy"></ContextMenuItem>
64+
<ContextMenuItem Icon="fa-solid fa-paste" Text="@Localizer["ContextMenuItemPast"]" OnClick="OnPaste"></ContextMenuItem>
65+
}
66+
else
67+
{
68+
<ContextMenuItem Icon="fa-solid fa-copy" Text="CopySub" OnClick="OnCopySub"></ContextMenuItem>
69+
}
6370
</ContextMenu>
6471
</ContextMenuZone>
6572
<ConsoleLogger @ref="_callbackLogger"></ConsoleLogger>

src/BootstrapBlazor.Server/Components/Samples/ContextMenus.razor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,22 @@ protected override void OnInitialized()
4141
Items = Foo.GenerateFoo(LocalizerFoo);
4242
}
4343

44+
TreeFoo? SelectModel = default;
4445
private Task OnBeforeShowCallback(object? item)
4546
{
4647
if (item is TreeFoo foo)
4748
{
4849
_callbackLogger.Log($"{foo.Text} trigger");
50+
SelectModel = foo;
4951
}
5052
return Task.CompletedTask;
5153
}
5254

55+
56+
Task OnCopySub(ContextMenuItem item, object value)
57+
{
58+
return Task.CompletedTask;
59+
}
5360
private bool OnDisabledCallback(ContextMenuItem item, object? context)
5461
{
5562
var ret = false;

src/BootstrapBlazor.Server/Locales/en-US.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6087,7 +6087,7 @@
60876087
"ContextMenuTreeTitle": "Tree",
60886088
"ContextMenuTreeIntro": "Right click on the <code>Tree</code> to pop up a context menu",
60896089
"ContextMenuCallbackTitle": "ContextMenu Callback",
6090-
"ContextMenuCallbackIntro": "By setting the <code>ContextMenu</code> component parameter <code>OnBeforeShowCallback</code>, you can get the callback event before the right-click menu pops up, which can be used for data preparation",
6090+
"ContextMenuCallbackIntro": "By setting the <code>ContextMenu</code> component parameter <code>OnBeforeShowCallback</code>, you can get the callback event before the right-click menu pops up, which can be used for data preparation or render menus based on conditions",
60916091
"ContextMenuDisabledTitle": "OnDisabledCallback",
60926092
"ContextMenuDisabledIntro": "By setting the <code>ContextMenuItem</code> component parameter <code>OnDisabledCallback</code> callback method, you can set whether the current right-click option is disabled."
60936093
},

src/BootstrapBlazor.Server/Locales/zh-CN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6087,7 +6087,7 @@
60876087
"ContextMenuTreeTitle": "Tree 组件",
60886088
"ContextMenuTreeIntro": "点击 <code>Tree</code> 组件行数据右键,弹出上下文关联菜单",
60896089
"ContextMenuCallbackTitle": "ContextMenu 回调",
6090-
"ContextMenuCallbackIntro": "通过设置 <code>ContextMenu</code> 组件参数 <code>OnBeforeShowCallback</code> 获得右键菜单弹出前回调事件,可用于数据准备工作",
6090+
"ContextMenuCallbackIntro": "通过设置 <code>ContextMenu</code> 组件参数 <code>OnBeforeShowCallback</code> 获得右键菜单弹出前回调事件,可用于数据准备工作,也可按需渲染菜单",
60916091
"ContextMenuDisabledTitle": "禁止回调方法",
60926092
"ContextMenuDisabledIntro": "通过设置 <code>ContextMenuItem</code> 组件参数 <code>OnDisabledCallback</code> 回调方法可用于设置当前右键选项是否禁用逻辑"
60936093
},

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.2.8-beta02</Version>
4+
<Version>9.2.8-beta03</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

0 commit comments

Comments
 (0)