Skip to content

Commit 43f1783

Browse files
authored
refactor(Checkbox): update the state value callback (#4646)
* fix: 修复 Checkbox 回传 state 值始终有值问题 * chore: bump version 9.0.0-rc.2.11.11.0 * doc: 更新示例 * doc: 更新示例文档 * doc: 补充 IsVirtualize 参数文档
1 parent a4084e7 commit 43f1783

File tree

6 files changed

+33
-17
lines changed

6 files changed

+33
-17
lines changed

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

+13-13
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,6 @@
2323
<p>@((MarkupString)Localizer["TreeViewsTips11"].Value)</p>
2424
<p>@((MarkupString)Localizer["TreeViewsTips12"].Value)</p>
2525

26-
<DemoBlock Title="@Localizer["TreeViewVirtualizeTitle"]"
27-
Introduction="@Localizer["TreeViewVirtualizeIntro"]"
28-
Name="DefaultExpand">
29-
<section ignore>
30-
@((MarkupString)Localizer["TreeViewVirtualizeDescription"].Value)
31-
</section>
32-
<div style="height: 400px">
33-
<TreeView TItem="TreeFoo" Items="@VirtualizeItems" ShowCheckbox="true" IsVirtualize="true"
34-
AutoCheckChildren="true" AutoCheckParent="true"
35-
OnExpandNodeAsync="OnExpandVirtualNodeAsync"></TreeView>
36-
</div>
37-
</DemoBlock>
38-
3926
<DemoBlock Title="@Localizer["TreeViewNormalTitle"]"
4027
Introduction="@Localizer["TreeViewNormalIntro"]"
4128
Name="Normal">
@@ -211,6 +198,19 @@
211198
EnableKeyboard="true" ClickToggleNode="false" ClickToggleCheck="false" ShowCheckbox="true" />
212199
</DemoBlock>
213200

201+
<DemoBlock Title="@Localizer["TreeViewVirtualizeTitle"]"
202+
Introduction="@Localizer["TreeViewVirtualizeIntro"]"
203+
Name="DefaultExpand">
204+
<section ignore>
205+
@((MarkupString)Localizer["TreeViewVirtualizeDescription"].Value)
206+
</section>
207+
<div style="height: 400px">
208+
<TreeView TItem="TreeFoo" Items="@VirtualizeItems" ShowCheckbox="true" IsVirtualize="true"
209+
AutoCheckChildren="true" AutoCheckParent="true"
210+
OnExpandNodeAsync="OnExpandVirtualNodeAsync"></TreeView>
211+
</div>
212+
</DemoBlock>
213+
214214
<AttributeTable Items="@GetAttributes()"></AttributeTable>
215215

216216
<AttributeTable Items="@GetTreeItemAttributes()" Title="@Localizer["TreeViewsAttribute"]"></AttributeTable>

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

+8
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ private static AttributeItem[] GetAttributes() =>
354354
DefaultValue = "false"
355355
},
356356
new()
357+
{
358+
Name = nameof(TreeView<string>.IsVirtualize),
359+
Description = "Virtualize",
360+
Type = "bool",
361+
ValueList = "true|false",
362+
DefaultValue = "false"
363+
},
364+
new()
357365
{
358366
Name = nameof(TreeView<string>.CanExpandWhenDisabled),
359367
Description = "Whether to expand when the control node is disabled",

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,10 @@
709709
"TreeViewMaxSelectedCountIntro": "Control the maximum number of selectable items by setting the <code>MaxSelectedCount</code> property, and handle the logic through the <code>OnMaxSelectedCountExceed</code> callback",
710710
"TreeViewMaxSelectedCountDesc": "When more than 2 nodes are selected, a <code>Toast</code> prompt bar will pop up",
711711
"TreeViewEnableKeyboardArrowUpDownTitle": "Keyboard",
712-
"TreeViewEnableKeyboardArrowUpDownIntro": "Support keyboard up and down arrow operations by setting <code>EnableKeyboardArrowUpDown=\"true\"</code>. <kbd>ArrowLeft</kbd> collapse the node, <kbd>ArrowRight</kbd> expand the node, <kbd>ArrowUp</kbd> move the node up, <kbd>ArrowDown</kbd> move the node down, <kbd>Space</kbd> select the node,"
712+
"TreeViewEnableKeyboardArrowUpDownIntro": "Support keyboard up and down arrow operations by setting <code>EnableKeyboardArrowUpDown=\"true\"</code>. <kbd>ArrowLeft</kbd> collapse the node, <kbd>ArrowRight</kbd> expand the node, <kbd>ArrowUp</kbd> move the node up, <kbd>ArrowDown</kbd> move the node down, <kbd>Space</kbd> select the node,",
713+
"TreeViewVirtualizeTitle": "Virtualize",
714+
"TreeViewVirtualizeIntro": "Enable virtual scrolling by setting <code>IsVirtualize=\"true\"</code> to support big data",
715+
"TreeViewVirtualizeDescription": "The component uses <code>Virtualize</code> to implement virtual scrolling logic, which reduces the pressure on the browser. However, if there is a lot of tree structure data, such as <b>Select All</b>, all data must be marked, resulting in large data in the memory. This problem has not been solved yet. Currently, this component still puts a lot of pressure on the <b>CPU</b> due to large data."
713716
},
714717
"BootstrapBlazor.Server.Components.Samples.Trees": {
715718
"TreeIntro": "<p>Obsolete,The <a href=\"treeviews\" alt=\"treeview\">TreeView</a> provides more functions",

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,10 @@
709709
"TreeViewMaxSelectedCountIntro": "通过设置 <code>MaxSelectedCount</code> 属性控制最大可选数量,通过 <code>OnMaxSelectedCountExceed</code> 回调处理逻辑",
710710
"TreeViewMaxSelectedCountDesc": "选中节点超过 2 个时,弹出 <code>Toast</code> 提示栏",
711711
"TreeViewEnableKeyboardArrowUpDownTitle": "键盘支持",
712-
"TreeViewEnableKeyboardArrowUpDownIntro": "通过设置 <code>EnableKeyboardArrowUpDown=\"true\"</code> 支持键盘上下箭头操作。<kbd>左箭头</kbd> 收起节点,<kbd>右箭头</kbd> 展开节点,<kbd>上箭头</kbd> 向上移动节点,<kbd>下箭头</kbd> 向下移动节点,<kbd>空格</kbd> 选中节点"
712+
"TreeViewEnableKeyboardArrowUpDownIntro": "通过设置 <code>EnableKeyboardArrowUpDown=\"true\"</code> 支持键盘上下箭头操作。<kbd>左箭头</kbd> 收起节点,<kbd>右箭头</kbd> 展开节点,<kbd>上箭头</kbd> 向上移动节点,<kbd>下箭头</kbd> 向下移动节点,<kbd>空格</kbd> 选中节点",
713+
"TreeViewVirtualizeTitle": "虚拟滚动",
714+
"TreeViewVirtualizeIntro": "通过设置 <code>IsVirtualize=\"true\"</code> 开启虚拟滚动,支持大数据",
715+
"TreeViewVirtualizeDescription": "组件内部使用 <code>Virtualize</code> 来实现虚拟滚动逻辑,对浏览器压力会减少很多;但是如果树状结构数据比较多,比如 <b>全选</b> 等操作必须对所有数据进行标记,导致内存中确实有大数据存在,目前还没有解决这个问题,目前此组件由于大数据对 <b>CPU</b> 压力还是比较大的"
713716
},
714717
"BootstrapBlazor.Server.Components.Samples.Trees": {
715718
"TreeIntro": "<p>本组件已弃用,请使用新组件 <a href=\"treeviews\" alt=\"treeview\">TreeView</a> 提供更多功能",

src/BootstrapBlazor/BootstrapBlazor.csproj

+1-1
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.0.0-rc.2.11.10.2</Version>
4+
<Version>9.0.0-rc.2.11.11.0</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Checkbox/Checkbox.razor.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export function init(id, invoke, method) {
1414
}
1515

1616
const state = el.getAttribute("data-bb-state");
17+
let val = null;
1718
if (state) {
19+
val = state == "1" ? 0 : 1;
1820
el.removeAttribute('data-bb-state');
1921

2022
if (state === "1") {
@@ -24,7 +26,7 @@ export function init(id, invoke, method) {
2426
el.parentElement.classList.add('is-checked');
2527
}
2628
}
27-
const result = await invoke.invokeMethodAsync(method, state == "1" ? 0 : 1);
29+
const result = await invoke.invokeMethodAsync(method, val);
2830
if (result === false) {
2931
e.preventDefault();
3032
}

0 commit comments

Comments
 (0)