This is a migrated thread and some comments may be shown as answers.

Custom Drop Down

2 Answers 196 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 18 May 2012, 06:59 PM
Is there an easy way to add a custom drop down to the editor tool menu?

Thanks!

EDIT - To be more clear, I want to add a new combobox to the menu in the same style as the defaults.

2 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 23 May 2012, 01:20 PM
Hello Jeff,

Custom tools can render a template, so you can work with that -- there is no official method for adding new drop-downs. If you feel comfortable with reusing the editor selectbox code, you can do so through the following snippet (note that using the internal widget may break without notice in future versions; using a kendoDropDown is possible):

$("#editor").kendoEditor({
    tools: [
        {
            name: "insertSnippet",
            tooltip: "Insert snippet",
            template: '<li class="k-editor-selectbox">' +
                  '<select class="insertSnippet"></select>' +
                '</li>'
        }
    ]
});

var ui = $(".insertSnippet");

// initialize the internal editor selectbox widget. could be any official kendo plug-in instead.
var selectBox = new kendo.ui.editor.SelectBox(ui, {
    dataTextField: "Text",
    dataValueField: "Value",
    dataSource: [
        { Text: "one", Value: "one" },
        { Text: "two", Value: "two" }
    ],
    change: function (e) {
        alert("changed!");
    },
    highlightFirst: false
});

// add 'unselectable' attribute so that tools persist selection when clicked
ui.closest(".k-widget").removeClass("k-insertSnippet").find("*").andSelf().attr("unselectable", "on");

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jeff
Top achievements
Rank 1
answered on 23 May 2012, 08:54 PM

This is exactly what I was looking for. Thanks!
Tags
Editor
Asked by
Jeff
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or