All Components

Data Binding

The DropDownButton enables you to bind data of the primitive (strings and numbers) or of the complex (data inside objects) type.

Arrays of Primitive Data

The following example demonstrates how to bind the DropDownButton to an array of primitive data.

@Component({
    selector: 'my-app',
    template: `
        <div class="example-wrapper">
            <kendo-dropdownbutton [data]="data">
                User Settings
            </kendo-dropdownbutton>
        </div>
    `
})
class AppComponent {
    data: Array<string> = ["My Profile", "Friend Requests", "Account Settings", "Support", "Log Out"];
}

Arrays of Complex Data

When the DropDownButton is bound to complex data (objects), 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 text field in the data objects is named text, the DropDownButton gets its value automatically. However, if the name of the property in the data source is different—for example, actionText—you have to set it as a textField.

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

For a list of all fields the items model uses, refer to the article on the ListItemModel configuration.

@Component({
    selector: 'my-app',
    template: `
        <kendo-dropdownbutton [data]="data" [textField]="'actionName'">
            Edit
        </kendo-dropdownbutton>
    `
})
class AppComponent {
    data: Array<any> = [{
        actionName: 'Undo',
        icon: 'undo',
        click: (dataItem) => {
            console.log(`${dataItem.actionName}ing last action.`);
        }
    }, {
        actionName: 'Redo',
        icon: 'redo',
        disabled: true
    }, {
        actionName: 'Cut',
        icon: 'cut'
    }, {
        actionName: 'Copy',
        icon: 'copy'
    }, {
        actionName: 'Paste',
        icon: 'paste'
    }];
}
In this article