New to Kendo UI for jQueryStart a free 30-day trial

Add Fonts to the Spreadsheet Fonts List

Environment

ProductProgress® Kendo UI® Spreadsheet for jQuery
Operating SystemAll
BrowserAll
Preferred LanguageJavaScript

Description

How can I add a font to the drop-down font list of the Spreadsheet?

Solution

  1. Reference the stylesheet of the font.
  2. Set the list with the fonts to the reference of the DropDownList which contains the fonts.
  3. Implement the select event of the widget.
  4. Check the current selection and apply the selected font.
    <div id="spreadsheet"></div>
    <script>
        $("#spreadsheet").kendoSpreadsheet({
            sheets: [{
                rows: [{
                    cells: [{ value: "A" }, { value: "B" }, { value: "C" }]
                }, {
                    cells: [{ value: "1" }, { value: "2" }, { value: "3" }]
                }, {
                    cells: [{ value: "4" }, { value: "5" }, { value: "6" }]
                }, {
                    cells: [{ value: "Lorem ipsum" },
                            { value: "sed do eiusmod" },
                            { value: "Ut enim ad minim" }]
                }]
            }],
            pdf: {
                area: "selection"
            }
        });

        var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");

      	var ddls = $('.k-spreadsheet-toolbar [data-role="dropdownlist"]')[0];
      	var ddl = $(ddls).data("kendoDropDownList");
      	var dataSource = new kendo.data.DataSource({
  					data: [ "Arial", "Verdana", "Lobster" ]
				});
      	ddl.setDataSource(dataSource);

      	ddl.bind("select", onSelect);

      	function onSelect(e){        	
          	var fontName = e.item.text();
          	var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
    		var sheet = spreadsheet.activeSheet();    
          	var selection = sheet.selection();
    		selection.fontFamily(fontName);
        }       	
    </script>
In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support