Kendo scheduler set local timezone default when add new event

5 posts, 3 answers
  1. Lam
    Lam avatar
    2 posts
    Member since:
    Feb 2016

    Posted 26 Sep Link to this post

    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?

  2. Answer
    Tyler
    Tyler avatar
    24 posts
    Member since:
    Feb 2017

    Posted 26 Sep in reply to Lam Link to this post

    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.

  3. Lam
    Lam avatar
    2 posts
    Member since:
    Feb 2016

    Posted 27 Sep in reply to Tyler Link to this post

    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? 

  4. Answer
    Tyler
    Tyler avatar
    24 posts
    Member since:
    Feb 2017

    Posted 27 Sep in reply to Lam Link to this post

    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.

  5. Answer
    Tyler
    Tyler avatar
    24 posts
    Member since:
    Feb 2017

    Posted 27 Sep in reply to Tyler Link to this post

    America/Chicago will also be next to the start and end dates in the editor right away when you open it.
Back to Top