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

Kendo scheduler set local timezone default when add new event

4 Answers 334 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Lam
Top achievements
Rank 1
Lam asked on 26 Sep 2017, 07:48 AM

Hi,

 

I'm working on kendo scheduler : http://dojo.telerik.com/@n2lose/ogUzay/2

1. Is there any way to set selected local timezone on the dialog add event? I would like to set local timezone selected when open dialog instead of user has to be selected from drop down list timezone!
I have researched and found the way to set timezone by the way set defaultValue for startTimezone, endTimezone. But normally, i just can get the timezoneOffset (number), how can i get the label timezone as we select an item in drop down list timezone?

 

2. When user selected an item from resources dataSource, can we custom template to add a link of that item below the drop down list? i mean i can custom template when handle on resources dataSource?

4 Answers, 1 is accepted

Sort by
0
Accepted
Tyler
Top achievements
Rank 1
answered on 26 Sep 2017, 01:54 PM

1. Not really... unless you use a library like moment.js. There isn't a way that is supported in all browsers to get the offset of a timezone given just the name of the timezone. Your best bet would be to use a library to handle this. This post from stackoverflow gives some good libraries to use and some good information: timezones (using a library like moment.js will give you functionality to find offsets based on timezone names and timezone names based on offsets).

 

2. You may have to utilize custom editor template and construct the things in your event editor yourself. That way you can add an element that is hidden, then when the Owner drop down changes (which it has a change event you can listen for and describe your own function for handling what happens when it changes) you can unhide and set the content of the element to the link you want. Then if nothing is selected, hide it again. This example shows how to set up a basic custom editor template.

0
Lam
Top achievements
Rank 1
answered on 27 Sep 2017, 03:37 PM

Thanks Tyler,

I am thinking use moment.js to get the name of local timezone. As i researched and looking for on stackoverflow, seems its ok.

But after i get the name of local timezone, how can i make it select that item in the drop down list timezone on editor event template, and it will apply and show the current local timezone beside on start/end datetime fields? 

0
Accepted
Tyler
Top achievements
Rank 1
answered on 27 Sep 2017, 08:05 PM

Here is a dojo that shows how to do this. I added comments. Listen for the edit event of the scheduler like I do in the example dojo, this fires whenever you open the editor. Grab the timezoneeditor, then set the value to the name of the timezone you discovered the user is currently in from using moment.js. I also showed how to listen to the change event of the timezone editor in case you need to do that as well. 

You will note that when you open the timezone editor, US Central timezone is chosen for the first drop down, and Chicago is chosen for the second already for you.

0
Accepted
Tyler
Top achievements
Rank 1
answered on 27 Sep 2017, 08:06 PM
America/Chicago will also be next to the start and end dates in the editor right away when you open it.
Tags
Scheduler
Asked by
Lam
Top achievements
Rank 1
Answers by
Tyler
Top achievements
Rank 1
Lam
Top achievements
Rank 1
Share this question
or