Add and Remove Items in Blazor SplitButton Component
18 Dec 20231 minute to read
Split Button component can dynamically add or remove items using AddItems, RemoveItems method.
@using Syncfusion.Blazor.SplitButtons
@using Syncfusion.Blazor.Buttons
<SfSplitButton Content="Paste Items" @ref="SplitbuttonRef">
<DropDownMenuItems>
<DropDownMenuItem Text="Paste"></DropDownMenuItem>
</DropDownMenuItems>
</SfSplitButton>
<div>
<SfButton Content="Additem" IsPrimary="true" @onclick="addItem"></SfButton>
<SfButton Content="Removeitem" IsPrimary="true" @onclick="removeItem"></SfButton>
</div>
@code {
SfSplitButton SplitbuttonRef;
private void addItem()
{
SplitbuttonRef.AddItems(SplitbtnItems);
}
private void removeItem()
{
SplitbuttonRef.RemoveItems(removeItems);
}
public List<DropDownMenuItem> SplitbtnItems = new List<DropDownMenuItem>
{
new DropDownMenuItem{ Text="Paste Special" },
new DropDownMenuItem{ Text="Paste as Formula" },
new DropDownMenuItem{ Text="Paste as Hyperlink" }
};
public List<string> removeItems = new List<string>()
{
"Paste"
};
}