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

Add fonts to fontFamily toolbar menu

6 Answers 409 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
B Jones
Top achievements
Rank 1
B Jones asked on 16 Nov 2017, 10:25 PM

The standard fontFamily toolbar menu lists the following fonts: "Arial", "Courier New", "Georgia", "Times New Roman", "Trebuchet MS", "Verdana"

 

I'd like to add additional ones to the list but haven't been able to figure out how. There appears to be support for customizing the list by setting a fontFamilies property somewhere, but I haven't been able to figure out where to do this or how to get a reference to the drop down list.

 

Thanks

 

6 Answers, 1 is accepted

Sort by
0
Accepted
Neli
Telerik team
answered on 20 Nov 2017, 02:52 PM
Hello,

There is a possibility in the Spreadsheet, fontFamily to be set to specific range in the sheet. But currently there is no built in configuration which allows you to add a font to the Spreadsheet font list in the toolbar dropdown.

You could use the fontFamily method and the approach described below to achieve the desired functionality.

The stylesheets of the newly added fonts should be referenced.
For example:

You could get a reference of the DropDownList which contains the fonts
var ddls = $('.k-spreadsheet-toolbar [data-role="dropdownlist"]')[0];
var ddl = $(ddls).data("kendoDropDownList");

Then, you could set the list of the fonts using DropDownList setDataSource method
var dataSource = new kendo.data.DataSource({
    data: [ "Arial", "Verdana", "Lobster" ]
});
ddl.setDataSource(dataSource);

You need to subscribe to the 'select' event of the DropDownList
ddl.bind("select", onSelect);

In the select event handler, you could check the selected font. A reference of the Spreadsheet widget is needed. You could check the current selection by using selection() method. The font could be applied, by using range fontFamily method
function onSelect(e){          
var fontName = e.item.text();
var spreadsheet = $("#spreadsheet").data("kendoSpreadsheet");
var sheet = spreadsheet.activeSheet();   
var selection = sheet.selection();
selection.fontFamily(fontName);
}

I hope that you will find the linked Dojo example helpful.


Regards,
Neli
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
B Jones
Top achievements
Rank 1
answered on 20 Nov 2017, 07:32 PM
Thanks Neli!
0
do van
Top achievements
Rank 1
answered on 01 Apr 2021, 05:51 PM

Hi Neil,

How can I do it for Vue wrapper component?

0
Petar
Telerik team
answered on 05 Apr 2021, 08:55 AM

Hi Do Van,

I've already answered your question in a support ticket and we are going to close the current thread. I won't post the solution here as the current discussion is about Kendo UI for jQuery and not for Kendo UI for Vue.

Regards,
Petar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
do van
Top achievements
Rank 1
answered on 07 Apr 2021, 03:49 AM

Hi Petar,

My question is created before support ticket, when I find solution for add more font.

I'm sorry for bothering you!

0
Petar
Telerik team
answered on 07 Apr 2021, 07:58 AM

Hi Do Van,

There is no need to apologize. Everything is OK.

I wrote my previous reply just to not leaving your question without a reply :) 

Regards,
Petar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Spreadsheet
Asked by
B Jones
Top achievements
Rank 1
Answers by
Neli
Telerik team
B Jones
Top achievements
Rank 1
do van
Top achievements
Rank 1
Petar
Telerik team
Share this question
or