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

Customize editortemplate on creating new event?

4 Answers 187 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Allan
Top achievements
Rank 1
Veteran
Allan asked on 25 Jan 2021, 09:05 AM

Hello,

In my custom editortemplate I am checking which type of task/appoinment is being clicked on, so I am able to change the design of the editortemplate based on which type it is. Eg. I am using the "<div data-bind="visible: IsActivityAppointment">".

But how do I determine if it's a new event being created and set the editortemplate from that?

//Allan

4 Answers, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 27 Jan 2021, 07:35 AM

Hi Alian,

I would suggest taking a look at the article from our documentation linked below regarding customizing the editor templates depending if the event is new or edited:

- https://docs.telerik.com/kendo-ui/controls/scheduling/scheduler/how-to/editing/modify-editor-when-event-is-new

In case, for example, you need to open the popup edit window only for editing, you could subscribe to the edit event of the Scheduler and check if the event is new as demonstrated below:

 

edit: function (e) {
    if (e.event.isNew()) {
        e.preventDefault();
    }
}

 

Here is a Dojo example where this is demonstrated.

I hope the provided suggestions will be helpful. Let me know in case you need additional assistance on the matter.

Regards,
Neli
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
Allan
Top achievements
Rank 1
Veteran
answered on 28 Jan 2021, 12:26 PM

Hi Neli,

I tried that and at first glance it works. But when I am editing an existing event it "sees" that as a new event and therefore uses my isNew() template.

It only occurs when I click "Edit current occurence". When I click "Edit the series" it shows the correct template. 

Do you have any suggestions?

I hope my explanation makes sense to you.

 

//Allan

0
Neli
Telerik team
answered on 01 Feb 2021, 09:15 AM

Hi Allan,

In order to perform an additional check for the recurring events, you could also check for example the recurrenceId of the events. I used the provided example in my previous reply and modified the editor template slightly. Below you will find the modifications marked in yellow:

# if(data.recurrenceId !== null && data.recurrenceId <= 0){#
<div data-bind="visible: isNew">
  <div class="k-edit-label"><label for="title">Title NEW NEW NEW</label></div>
  <div data-container-for="title" class="k-edit-field">
      <input type="text" class="k-textbox" name="title" required="required" data-bind="value:title">
  </div>
</div>
# } else if (data.recurrenceId > 0) {#
  <h4>The 'Title' field is hidden, because event is not new</h4>
# } #

Here is also the modified Dojo example.

I remain at your disposal for any further questions regarding the issue.

 

Regards,
Neli
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
Allan
Top achievements
Rank 1
Veteran
answered on 04 Feb 2021, 12:59 PM

Thank you Neli.

I will have a look at that.

//Allan

Tags
Scheduler
Asked by
Allan
Top achievements
Rank 1
Veteran
Answers by
Neli
Telerik team
Allan
Top achievements
Rank 1
Veteran
Share this question
or