Skip to content

Commit 2f59a8d

Browse files
ArgoZhangshakugans
andauthored
feat(Table): disable editing in virtual scroll mode (#6399)
* refactor: 重构逻辑保证虚拟滚动模式下禁止编辑 * feat: 虚拟滚动模式下禁止编辑 * chore: bump version 9.8.1-beta06 Co-Authored-By: shakugans <[email protected]> --------- Co-authored-by: shakugans <[email protected]>
1 parent c70eca9 commit 2f59a8d

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

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.8.1-beta05</Version>
4+
<Version>9.8.1-beta06</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/Table/Table.razor

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747
}
4848
@if (ShowDefaultButtons)
4949
{
50-
@if (ShowAddButton)
50+
@if (ShowAddButton && ScrollMode == ScrollMode.None)
5151
{
5252
<TableToolbarButton TItem="TItem" Color="Color.Success" OnClick="AddAsync" Icon="@AddButtonIcon" Text="@AddButtonText" IsDisabled="GetAddButtonStatus()" />
5353
}
54-
@if (!IsExcel && ShowEditButton)
54+
@if (!IsExcel && ShowEditButton && ScrollMode == ScrollMode.None)
5555
{
5656
<TableToolbarButton TItem="TItem" IsDisabled="GetEditButtonStatus()" Color="Color.Primary" OnClick="EditAsync" Icon="@EditButtonIcon" Text="@EditButtonText" IsEnableWhenSelectedOneRow="true" />
5757
}
@@ -366,17 +366,6 @@
366366
@RenderHeader(false)
367367
}
368368
<tbody>
369-
@if (InsertRowMode == InsertRowMode.First)
370-
{
371-
if (!IsExcel && EditMode == EditMode.EditForm && ShowAddForm)
372-
{
373-
@RenderEditForm.Invoke((EditModel, ItemChangedType.Add))
374-
}
375-
if (AddInCell)
376-
{
377-
@RenderRow(EditModel)
378-
}
379-
}
380369
@if (ScrollMode == ScrollMode.Virtual)
381370
{
382371
@if (Items != null)
@@ -394,7 +383,18 @@
394383
}
395384
else
396385
{
397-
@foreach (var item in Rows)
386+
if (InsertRowMode == InsertRowMode.First)
387+
{
388+
if (!IsExcel && EditMode == EditMode.EditForm && ShowAddForm)
389+
{
390+
@RenderEditForm.Invoke((EditModel, ItemChangedType.Add))
391+
}
392+
if (AddInCell)
393+
{
394+
@RenderRow(EditModel)
395+
}
396+
}
397+
foreach (var item in Rows)
398398
{
399399
OnBeforeRenderRow?.Invoke(item);
400400
if (RowTemplate != null)
@@ -439,7 +439,18 @@
439439
@RenderEditForm((EditModel, ItemChangedType.Update))
440440
}
441441
}
442-
@if (IsShowEmpty)
442+
if (InsertRowMode == InsertRowMode.Last)
443+
{
444+
if (!IsExcel && EditMode == EditMode.EditForm && ShowAddForm)
445+
{
446+
@RenderEditForm.Invoke((EditModel, ItemChangedType.Add))
447+
}
448+
if (AddInCell)
449+
{
450+
@RenderRow(EditModel)
451+
}
452+
}
453+
if (IsShowEmpty)
443454
{
444455
<tr>
445456
<td colspan="@GetEmptyColumnCount()">
@@ -449,17 +460,6 @@
449460
</tr>
450461
}
451462
}
452-
@if (InsertRowMode == InsertRowMode.Last)
453-
{
454-
if (!IsExcel && EditMode == EditMode.EditForm && ShowAddForm)
455-
{
456-
@RenderEditForm.Invoke((EditModel, ItemChangedType.Add))
457-
}
458-
if (AddInCell)
459-
{
460-
@RenderRow(EditModel)
461-
}
462-
}
463463
</tbody>
464464
@if (IsShowFooter)
465465
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ private Task ExportExcelAsync() => ExecuteExportAsync(() => OnExportAsync != nul
12191219
/// 是否显示行内编辑按钮
12201220
/// </summary>
12211221
/// <returns></returns>
1222-
protected bool GetShowExtendEditButton(TItem item) => ShowExtendEditButtonCallback?.Invoke(item) ?? ShowExtendEditButton;
1222+
protected bool GetShowExtendEditButton(TItem item) => ScrollMode != ScrollMode.Virtual && (ShowExtendEditButtonCallback?.Invoke(item) ?? ShowExtendEditButton);
12231223

12241224
/// <summary>
12251225
/// 是否显示行内删除按钮

0 commit comments

Comments
 (0)