@namespace Radzen.Blazor
@using Radzen.Blazor
@using Radzen.Blazor.Spreadsheet
@using Radzen.Blazor.Spreadsheet.Tools
@using Radzen.Documents.Spreadsheet
@inject DialogService DialogService
@inherits RadzenSpreadsheetToolBase
@code {
protected override SpreadsheetFeature? Feature => SpreadsheetFeature.ConditionalFormatting;
private async Task OnClickAsync(RadzenSplitButtonItem? item)
{
if (Worksheet is null || Worksheet.Selection.Cell == CellRef.Invalid)
{
return;
}
var ruleType = item?.Value switch
{
"less" => ConditionalFormatRuleType.LessThan,
"between" => ConditionalFormatRuleType.Between,
"equal" => ConditionalFormatRuleType.EqualTo,
"text" => ConditionalFormatRuleType.TextContains,
_ => ConditionalFormatRuleType.GreaterThan
};
var result = await DialogService.OpenAsync(Spreadsheet?.Localize(nameof(RadzenStrings.Spreadsheet_ConditionalFormattingTitle)) ?? "Conditional Formatting",
new Dictionary
{
{ "RuleType", ruleType },
{ "Culture", Worksheet.Culture }
});
if (result is ConditionalFormatBase rule && Spreadsheet is not null)
{
var command = new ConditionalFormatCommand(Worksheet, Worksheet.Selection.Range, rule);
await Spreadsheet.ExecuteAsync(command);
}
}
}