Angular + Kendo UI: DropDown Button (2024)

In our quest to beautifying the web, we present more “cool” UI available for the humble Kendo UI button.

The Kendo UI DropDownButton is a component that is available in {ButtonsModule} from
‘@progress/kendo-angular-buttons’.

For using Kendo UI buttons, you need to install Kendo in your Angular application. To learn the process of installation, follow my previous article and make your Angular app ready.


Power up your Angular 5 Application with KendoUI

You need to complete the Angular v5 app along with Kendo UI Buttons module before continuing with the following:

DropDownButton looks like the Button but when you click, it displays a popup list with items. DropDownButton also allows us binding a list or an array with multiple values from an Angular component.

If you have any Array like this in any Component and want to show this array’s values as a list of options in the DropDownButton, you can do that using the following code.


data: Array<any> = [{

text: ‘My Profile’

}, {text: ‘Friend Requests’},

{text: ‘Account Settings’},

{text: ‘Support’},

{ text: ‘Log Out’}];

Now, in app.component.html, add a Kendo DropDownButton.
<kendo-dropdownbutton></kendo-dropdownbutton>

Kendo DropDownButton has a property called “data” for binding the Options list with it.

<kendo-dropdownbutton [data]=“data”>
User Settings
</kendo-dropdownbutton>

Now, your DropDownButton must be something like the below image and when you click on it, it shows all options:
Angular + Kendo UI: DropDown Button (1)

Events Binding with DropDownButton

DropDownButton provides Events like:

  1. Focus
  2. Blur
  3. Open
  4. Close
  5. itemClick

Let’s have a look at how you can use any of these step by step:

Step 1. Create an Event Handler function in your Component Class.


public onItemClick (): void {

console.log (‘item click’);

}

Step 2. Use Angular Event Binding with your DropDownButton in component HTML file.

<kendo-dropdownbutton [data]=“data” (itemClick)=“onItemClick ()”>

User Settings

</kendo-dropdownbutton>

Step 3. Serve your Angular app in the browser and click on any available option in the DropDownButton.

Angular + Kendo UI: DropDown Button (2)

In a similar way, you can use more events of DropDownButton, as in the following code:

(focus)=“onFocus()”

(blur)=“onBlur()”

(close)=“onClose()”

(open)=“onOpen()”

DropDownButton With Icon

To beatify your DropDownButton, use Icon along with Text using [icon] property of Kendo UI DropDownButton.
<kendo-dropdownbutton [data]=“data” [icon]=“‘gear'” (itemClick)=“onItemClick ()”>

User Settings


</kendo-dropdownbutton>

And it’ll be more attractive for your Client.


Angular + Kendo UI: DropDown Button (3)

You can use other types of icons also like
FontAwsomeor Image Icon, so as to make the buttons more eye-catching, For example:

  1. FontAwsome
    Just use the CSS of FontAwsome in your Angular App.

<link
rel=“stylesheet”
href=https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css&#8221;>


<kendo-dropdownbutton [iconClass]=“iconClass”>

  1. Image Icon

Update the Component with Image URL in any variable, like:

imgIconURL:string=http://demos.telerik.com/kendo-ui/content/shared/icons/16/star.png&#8221;;

Now, use [imageUrl] in DropDownButton,

<kendo-dropdownbutton [data]=“data” [imageUrl]=“imgIconURL”>

Angular + Kendo UI: DropDown Button (4)

Must checkout the
built-in Kendo UI icons.

Popup Item Templates

This is really a best feature of DropDownButton. The Kendo UI DropDownButton provides options for setting the behavior of its popup and popup items with custom templates.

Step 1:

Add a new icon property and its value to your data array.
data: Array<any> = [{

text: ‘Cut’,icon: ‘cut’},

{text: ‘Paste’,icon: ‘paste’

}];

Now, use <ng-template></ng-template> for custom template and decorate it as you want.

<kendo-dropdownbutton [data]=“data”>
Edit

<ng-template
kendoDropDownButtonItemTemplate
let-dataItem>
<span
class=“k-icon k-i-{{ dataItem.icon }}”></span>
<span>{{ dataItem.text }}</span>
</ng-template>

</kendo-dropdownbutton>

Now, see the output. Well, it’s just awesome.

Angular + Kendo UI: DropDown Button (5)

Data Binding with DropDownButton

The DropDownButton enables you to bind the data with DropDownButton in two ways:

  1. Primitive (strings and numbers).

    You can bind an array to the DropDownButton with string and numbers’ data called as Primitive, which we did in our previous examples.

data: Array<any> = [{

text: ‘Cut’

}, {text: ‘Paste’

}];

If the text field in the data objects is named text, the DropDownButton gets its value automatically.

  1. Complex (data inside objects) type.

A Complex data type is just an object with multiple properties. The component extracts the text value from the data items and in this way, sets the text of the items in the popup. If the name of the property in data source is different from the text—for example, actionText — you have to set it as a [textField]. Here is an example –
data: Array<any> = [{

actionName: ‘Undo’,icon: ‘undo’},

{actionName: ‘Redo’,icon: ‘redo’},

{actionName: ‘Cut’,icon: ‘cut’},

{actionName: ‘Copy’,icon: ‘copy’ },

{actionName: ‘Paste’,icon: ‘paste’

}];

Now, set [textField] to “‘actionName'”.

<kendo-dropdownbutton [data]=“data” [textField]=“‘actionName'”>

Edit

</kendo-dropdownbutton>

And Check the output:
Angular + Kendo UI: DropDown Button (6)

We can add more properties like disabled, click, and more.

To set the enabled or disabled state of the DropDownButton, use disabled property. To set the icon of each item, use the icon, iconClass, and imageUrl properties of data items. To attach a function that will be called when the user clicks an item, set the click property of the data item.

  1. Disabled:

    Just add a new property “disabled: true” in the data object that you want to be Disabled. For example:

data: Array<any> = [{

actionName: ‘Undo’,icon: ‘undo’},

{actionName: ‘Redo’,icon: ‘redo’,disabled: true},

{ actionName: ‘Cut’, icon: ‘cut’},

{actionName: ‘Copy’,icon: ‘copy’},

{actionName: ‘Paste’,icon: ‘paste’,disabled: true

}];

Now, your output must be something like the below image.

Angular + Kendo UI: DropDown Button (7)

  1. Click:

Using Click Property of Data Items in DropDownButton, you can attach a function. Let us see how it’s work.

First, add a click property to the data object array.

{

actionName: ‘Undo’,

icon: ‘undo’,

click: (dataItem) => {

console.log(`Undo in process !!`);

}

}

And, serve your Angular app again.

Angular + Kendo UI: DropDown Button (8)

Keyboard Shortcut/Navigation

Kendo UI DropDownButton supports many shortcuts to make it more user-friendly from keyboard only. The keyboard navigation of the DropDownButton is enabled by default.

DropDownButton supports the following keyboard shortcuts:

SHORTCUT KEYSDESCRIPTION
Enter & SpaceOpens the popup, or activates the highlighted item and closes the popup.
Alt + Down ArrowOpens the popup.
Alt + Up ArrowCloses the popup.
EscCloses the popup.
Up Arrow & Left ArrowSets the focus on the previously available item.
Down Arrow & Right ArrowSets the focus on the next available item.

Earlier articles on using Kendo UI with Angular:

Button
Beautiful Buttons with Kendo UI in Angular v5 app

ButtonGroup
Tell me more: Kendo UI ButtonGroup in Angular v5App

Angular + Kendo UI: DropDown Button (2024)

FAQs

How do I add a DropDownList to my Kendo grid? ›

The steps are:
  1. Specify the DropDownList container as a FooterTemplate for one of the Grid's columns and initialize it with JavaScript on DataBound event of the Grid.
  2. On Change event of the DropDownList, the selected rows could be manipulated.
Dec 1, 2019

How to set dropdown in button in angular? ›

  1. DropDownButton. Getting Started. Create a DropDownButton. Configure the Button. Populate the Drop-Down Menu. Handle the Menu Item Click Event. Split the Button. Enable the Stateful Mode. Customize the Drop-Down Menu. API.
  2. Menu.
  3. Popup.

How do you inspect a kendo dropdown? ›

Click on the search bar of the Kendo Multiselect. This results in the expansion of a dropdown-like list of the possible multiselect items (each having its own checkbox). It is kind of a hybrid checkbox list embedded in a pulldown list. Very convenient for the end user.

What is the difference between kendo ComboBox and DropDownList? ›

The Kendo ComboBox is identical to the Kendo DropDownList with just one main difference- the ComboBox also allows the user to enter a custom value in the search bar. If the value does not match one of the values, the ComboBox allows you to launch a new interface to allow the user to enter the new value.

How do I make a kendo DropDownList required? ›

Solution. The DropDownList enables you to initialize it by using the input or the select element. If the selection from the DropDownList is mandatory, initialize it from an input or select element with a required attribute. The following example uses the Kendo UI Validator to display the validation message.

How do I add items to my Kendo DropDownList? ›

Adding New Items
  1. Initialize the DropDownList. <input id="products" style="width: 100%;" /> <script> $(document). ...
  2. Refer the data source of the DropDownList. var widget = $("#products"). ...
  3. Implement the confirmation dialog. if (confirm("Are you sure?")) { dataSource. ...
  4. Sync the data to update the records. dataSource.

How do you check if Kendo DropDownList is enabled? ›

Just do this: $("#your_dropdown_id"). attr("aria-disabled"); If it is disabled this returns true else it returns false.

How do I bind data to a kendo dropdown? ›

To initialize the DropDownList by binding the widget to a local data array and then utilizing the <input> or the <select> element, use the Kendo UI Data Source. The Data Source component is an abstraction for local and remote data. Local arrays are suitable for limited value options.

How do I remove items from kendo DropDownList? ›

Remove dropdown option from Kendo dropdownlist using jquery
  1. var ddl = $("#color").data("kendoDropDownList");
  2. var oldData = ddl.dataSource.data();
  3. ddl.dataSource.remove(oldData[0]); //remove first item.
  4. ddl.dataSource.remove(oldData[oldData.length - 1]); //remove last item.
  5. });
Sep 16, 2016

Is combo box same as DropDown? ›

A drop-down list box saves space (it can drop down to cover other dialog box controls temporarily). A combo box allows the user either to select an item from the list or type in a new item.

How do I disable kendo DropDown? ›

A possible approach to make items appear as disabled is to apply the k-disabled CSS class in a Kendo UI Template. To prevent the future selection of disabled items, add an event handler to the select event and call e. preventDefault() .

How do I add a DropDownList? ›

Select the cell in the worksheet where you want the drop-down list. Go to the Data tab on the Ribbon, then select Data Validation. On the Settings tab, in the Allow box, select List. If it's OK for people to leave the cell empty, check the Ignore blank box.

How do I make my Kendo grid sortable? ›

To enable the sorting functionality of the Grid, set the sortable option to true . As a result, the default single-column sorting functionality will be applied. To enhance the performance of the Grid, apply the sorting operations on the server by setting the serverSorting option of the data source to true .

Top Articles
Latest Posts
Article information

Author: Nathanial Hackett

Last Updated:

Views: 6031

Rating: 4.1 / 5 (72 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Nathanial Hackett

Birthday: 1997-10-09

Address: Apt. 935 264 Abshire Canyon, South Nerissachester, NM 01800

Phone: +9752624861224

Job: Forward Technology Assistant

Hobby: Listening to music, Shopping, Vacation, Baton twirling, Flower arranging, Blacksmithing, Do it yourself

Introduction: My name is Nathanial Hackett, I am a lovely, curious, smiling, lively, thoughtful, courageous, lively person who loves writing and wants to share my knowledge and understanding with you.