Files
radzen-blazor/Radzen.Blazor/Spreadsheet/Tools/RadzenSpreadsheetTableDesignToolset.razor
Atanas Korchev 98db8bd1fa Spreadsheet: prefix public toolbar tools with RadzenSpreadsheet, fix standalone Open/Save
Rename the 34 public toolbar tool components and the two public base classes
to the RadzenSpreadsheet* convention in the Radzen.Blazor namespace, matching
RadzenHtmlEditor*. This removes name collisions (Color, Bold, Open, Save...),
makes them discoverable via the Radzen prefix, and drops the special
@using Radzen.Blazor.Spreadsheet.Tools a custom toolbar previously needed.

Make Open and Save work in a custom toolbar: they now read the cascaded
context instead of host-wired parameters. Add ISpreadsheet.LoadWorkbookAsync
(one host render, reused by the built-in Open) so the grid refreshes on load;
Save derives the workbook from the cascaded Worksheet.

The internal dialogs and ConditionalFormatRuleType stay in their sub-namespace.
2026-06-15 18:45:19 +03:00

77 lines
1.9 KiB
Plaintext

@namespace Radzen.Blazor
@using Radzen.Blazor
@using Radzen.Blazor.Spreadsheet
@using Radzen.Documents.Spreadsheet
@implements IDisposable
<RadzenTabsItem Text=@(Spreadsheet?.Localize(nameof(RadzenStrings.Spreadsheet_TableDesignTab)) ?? "Table Design") Visible=@IsActive>
<TableDesignPanel Worksheet=@Worksheet />
</RadzenTabsItem>
@code {
#nullable enable
[CascadingParameter]
public Worksheet? Worksheet { get; set; }
[CascadingParameter]
public ISpreadsheet? Spreadsheet { get; set; }
private readonly EventBinding<Worksheet> worksheetBinding;
public RadzenSpreadsheetTableDesignToolset()
{
worksheetBinding = new EventBinding<Worksheet>(
w =>
{
w.Selection.Changed += OnSelectionChanged;
w.ChromeChanged += OnSelectionChanged;
},
w =>
{
w.Selection.Changed -= OnSelectionChanged;
w.ChromeChanged -= OnSelectionChanged;
});
}
private bool IsActive
{
get
{
if (Worksheet is null)
{
return false;
}
var sel = Worksheet.Selection.Cell;
if (sel == CellRef.Invalid)
{
return false;
}
foreach (var t in Worksheet.Tables)
{
if (t.Range.Contains(sel.Row, sel.Column))
{
return true;
}
}
return false;
}
}
protected override void OnParametersSet()
{
worksheetBinding.Bind(Worksheet);
}
// RadzenTabsItem.Visible is captured at parameter-set time, so we need an explicit
// StateHasChanged() each time selection moves into or out of a table.
private void OnSelectionChanged() => StateHasChanged();
public void Dispose()
{
worksheetBinding.Dispose();
}
}