Search code examples
kendo-uikendo-dropdown

How to add a Default text on Kendo Drop Down List?


I just want a custom text on the kendo dropdown list. But i have searched on internet and didn't get any solution. So, please any body help me here.

Here is my code:

$("#dropdownlist").kendoDropDownList({
        //headerTemplate: 'Filter by Name',
        dataSource: {
            data: [
                'Filter by Name',
                'Abcd',
                'Xyz',
                'Pqrs',
                'Mno'
            ]
        }
    });

Solution

  • I believe you are looking for 'optionLabel' which shows text for the default empty item. For example:

    $("#dropdownlist").kendoDropDownList({
            //headerTemplate: 'Filter by Name',
            dataSource: {
                data: [
                    'Filter by Name',
                    'Abcd',
                    'Xyz',
                    'Pqrs',
                    'Mno'
                ]
            },
            optionLabel: "Select an item..."
        });
    

    More details here: http://docs.telerik.com/kendo-ui/api/javascript/ui/dropdownlist#configuration-optionLabel