Search results

Item Configuration

The Toolbar can be rendered by defining an array of items. Items can be constructed with the following built-in command types or item template.

Button

Button is the default command Type, and it can be rendered by using the Text property. Properties of the button command type:

Property Description
Text The text to be displayed for button.
ID The ID of the button to be rendered. If the ID is not given, auto ID is generated.
PrefixIcon Defines the class used to specify an icon for the button. The icon is positioned before the text if text is available or the icon alone button is rendered.
SuffixIcon Defines the class used to specify an icon for the button. The icon is positioned after the text if text is available. If both PrefixIcon and SuffixIcon are specified, only PrefixIcon is considered.
Width Used to set the width of the button.

Separator

The Separator type adds a vertical separation between the Toolbar’s Single/Multiple commands.

@using Syncfusion.EJ2.Blazor.Navigations

<EjsToolbar>
  <ToolbarItems>
    <ToolbarItem Text="Cut"></ToolbarItem>
    <ToolbarItem Text="Copy"></ToolbarItem>
    <ToolbarItem Type="@ItemType.Separator"></ToolbarItem>
    <ToolbarItem Text="Paste"></ToolbarItem>
    <ToolbarItem Type="@ItemType.Separator"></ToolbarItem>
    <ToolbarItem Text="Undo"></ToolbarItem>
    <ToolbarItem Text="Redo"></ToolbarItem>
  </ToolbarItems>
</EjsToolbar>

If Separator is added as the first or the last item, it will not be visible.

Input

The Input type is only applicable for adding Template elements when the Template property is defined as an object. Input type creates an input element internally that acts as the container for Syncfusion input based components.

NumericTextBox

  • The NumericTextBox component can be included by importing the @using Syncfusion.EJ2.Blazor.Inputs package into the ~/_Imports.razor file.

  • Initialize the NumericTextBox in Template property, where the Toolbar item Type is set as Input.

  • Related NumericTextBox component properties can also be configured as given below.

<EjsNumericTextBox Format="n2"></EjsNumericTextBox>
  • The DropDownList component can be included by importing the @using Syncfusion.EJ2.Blazor.DropDowns package into the ~/_Imports.razor file.

  • Initialize the DropDownList in Template property, where the Toolbar item Type is set as Input.

  • Related DropDownList component properties can also be configured as given below.

<EjsDropdownList Width="100"></EjsDropdownList>

RadioButton

  • The RadioButton component can be included by importing the @using Syncfusion.EJ2.Blazor.Buttons package into the ~/_Imports.razor file.

  • Initialize the RadioButton in Template property, where the Toolbar item Type is set as Input.

  • Related RadioButton component properties can also be configured as given below.

<EjsRadioButton Label="Option 1" Name="Default"></EjsRadioButton>

The following code explains how to add NumericTextBox, DropDownList, RadioButton and CheckBox components to the Toolbar.

<EjsToolbar>
    <ToolbarItems>
        <ToolbarItem Type="ItemType.Input">
          <Template>
            <EjsNumericTextBox Width="150" Value=1 Format="c2"></EjsNumericTextBox>
          </Template>
        </ToolbarItem>
        <ToolbarItem></ToolbarItem>
        <ToolbarItem Type="ItemType.Input">
            <Template>
                <EjsDropDownList TValue="string" ID="Games" DataSource="@SportsData" Width="120" Index="2">
                    <DropDownListFieldSettings Value="Text"></DropDownListFieldSettings>
                </EjsDropDownList>
            </Template>
        </ToolbarItem>
        <ToolbarItem></ToolbarItem>
        <ToolbarItem Type="@ItemType.Input">
            <Template>
                <EjsCheckBox Checked="true" Label="CheckBox"></EjsCheckBox>
            </Template>
        </ToolbarItem>
        <ToolbarItem></ToolbarItem>
        <ToolbarItem Type="@ItemType.Input">
            <Template>
                <EjsRadioButton Label="Radio" Name="default" Checked="true"></EjsRadioButton>
            </Template>
        </ToolbarItem>
    </ToolbarItems>
</EjsToolbar>

@code {
    public class Games
    {
        public string ID { get; set; }
        public string Text { get; set; }
    }
    List<Games> SportsData = new List<Games> {
    new Games() { ID= "Game2", Text= "Badminton" },
    new Games() { ID= "Game4", Text= "Cricket" },
    new Games() { ID= "Game5", Text= "Football" },
    new Games() { ID= "Game6", Text= "Golf" },
    new Games() { ID= "Game10", Text= "Tennis"}
  };
}

Output be like the below.

Toolbar Control with item configuration