Skip to content

Commit 316eca5

Browse files
authored
feat(Table): add EnableKeyboardNavigationCell parameter (#6015)
* refactor: 增加 EnableKeyboardNavigationCell 参数 * refactor: 更新脚本 * test: 更新单元测试 * chore: bump version 9.6.2-beta03 * doc: 增加导出配置文档
1 parent 0a920d3 commit 316eca5

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5584,7 +5584,7 @@
55845584
"TablesExportShowExportCsvButtonTitle": "Export Csv/Pdf Button",
55855585
"TablesExportShowExportCsvButtonIntro": "Show/hide <code>Csv/Pdf</code> button by set <code>ShowExportCsvButton=\"true\"</code> <code>ShowExportPdfButton=\"true\"</code>",
55865586
"TablesExportOnExportAsyncTitle": "Custom export method",
5587-
"TablesExportOnExportAsyncIntro": "You can customize the export method by setting the <code>OnExportAsync</code> callback delegate method. If you don't set it, the built-in export function of the component will be used.",
5587+
"TablesExportOnExportAsyncIntro": "You can customize the export method by setting the <code>OnExportAsync</code> callback delegate method. If you don't set it, the built-in export function of the component will be used. You can set the column property <code>IgnoreWhenExport=\"true\"</code> to ignore this column when exporting",
55885588
"TablesExportButtonDropdownTemplateTitle": "Custom export dropdown button",
55895589
"TablesExportButtonDropdownTemplateIntro": "Customize the content of the export button dropdown box by setting the <code>ExportButtonDropdownTemplate</code> template",
55905590
"TablesExportButtonExcelText": "Export Page data - Excel",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5584,7 +5584,7 @@
55845584
"TablesExportShowExportCsvButtonTitle": "导出 Csv/Pdf",
55855585
"TablesExportShowExportCsvButtonIntro": "通过设置 <code>ShowExportCsvButton=\"true\"</code> <code>ShowExportPdfButton=\"true\"</code> 控制 <code>Csv/Pdf</code> 导出按钮",
55865586
"TablesExportOnExportAsyncTitle": "自定义导出方法",
5587-
"TablesExportOnExportAsyncIntro": "通过设置 <code>OnExportAsync</code> 回调委托方法可自定义导出方法,不设置将使用组件内置导出函数",
5587+
"TablesExportOnExportAsyncIntro": "通过设置 <code>OnExportAsync</code> 回调委托方法可自定义导出方法,不设置将使用组件内置导出函数,可通过设置列属性 <code>IgnoreWhenExport=\"true\"</code> 导出时忽略此列",
55885588
"TablesExportButtonDropdownTemplateTitle": "自定义导出下拉框按钮",
55895589
"TablesExportButtonDropdownTemplateIntro": "通过设置 <code>ExportButtonDropdownTemplate</code> 模板自定义导出按钮下拉框内容",
55905590
"TablesExportButtonExcelText": "导出当前页数据 Excel",

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.6.2-beta02</Version>
4+
<Version>9.6.2-beta03</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Table/Table.razor.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ private string GetSortTooltip(ITableColumn col) => SortName != col.GetFieldName(
250250
[Parameter]
251251
public bool IsExcel { get; set; }
252252

253+
/// <summary>
254+
/// 获得/设置 是否启用 Excel 模式下的键盘导航功能 默认 true
255+
/// </summary>
256+
[Parameter]
257+
public bool EnableKeyboardNavigationCell { get; set; } = true;
258+
253259
/// <summary>
254260
/// 获得/设置 是否显示明细行 默认为 null 为空时使用 <see cref="DetailRowTemplate" /> 进行逻辑判断
255261
/// </summary>
@@ -1054,7 +1060,8 @@ private async Task OnTableRenderAsync(bool firstRender)
10541060
Text = Localizer["AlignRightText"].Value,
10551061
Tooltip = Localizer["AlignRightTooltipText"].Value
10561062
}
1057-
}
1063+
},
1064+
EnableKeyboardNavigationCell
10581065
});
10591066
}
10601067

src/BootstrapBlazor/Components/Table/Table.razor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function reset(id) {
7676
table.tables.push(shim.firstChild)
7777
}
7878

79-
if (table.isExcel) {
79+
if (table.options.enableKeyboardNavigationCell === true && table.isExcel) {
8080
setExcelKeyboardListener(table)
8181
}
8282

@@ -232,7 +232,7 @@ const destroyTable = table => {
232232
EventHandler.off(table.body, 'scroll')
233233
}
234234

235-
if (table.isExcel) {
235+
if (table.options.enableKeyboardNavigationCell === true && table.isExcel) {
236236
EventHandler.off(table.element, 'keydown')
237237
}
238238

test/UnitTest/Components/TableTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using System.ComponentModel.DataAnnotations;
1212
using System.Data;
1313
using System.Reflection;
14-
using System.Runtime.CompilerServices;
1514

1615
namespace UnitTest.Components;
1716

@@ -581,6 +580,7 @@ public async Task ShowToolbar_IsExcel_Ok()
581580
{
582581
pb.Add(a => a.RenderMode, TableRenderMode.Table);
583582
pb.Add(a => a.IsExcel, true);
583+
pb.Add(a => a.EnableKeyboardNavigationCell, true);
584584
pb.Add(a => a.Items, items);
585585
pb.Add(a => a.OnSaveAsync, (foo, changedItem) =>
586586
{

0 commit comments

Comments
 (0)