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

How to get event id in custom editor on document ready?

2 Answers 153 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Jackie
Top achievements
Rank 1
Jackie asked on 30 Jun 2017, 04:50 PM

I'm using a custom editor to incorporate some extra fields we are saving with our events. I am trying to set up the editor so that certain fields are hidden on an event add, but show on an event edit. I'm trying to do this by running some jQuery on document ready of the custom editor, to test if the event id is 0. What I'm finding however, is that on that event, the id is always 0 and it doesn't populate until some time later.

Do you know of any way I can get that id when document ready fires for the custom editor? Or is there another event I can use that would have the appropriate timing to get the id in time to hide those fields?

Please let me know if any code examples would be helpful.

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Danchev
Telerik team
answered on 03 Jul 2017, 02:27 PM
Hi Jackie,

The Scheduler's edit event fires in both cases: when adding an event and when editing an existing one. You can detect whether the event is new either through its id, which will be 0 until the event is saved, or through its isNew method:
function onEdit(e) {
  // you can use either: if(e.event.id == 0) or:
  if(e.event.isNew()) {
    $("#custom-description").hide();
  }
}

So the logic in the handler above, hides an element with id "custom-description" when adding a new event. The logic does not execute when an existing event is edited and in that case the element remains visible.

Regards,
Ivan Danchev
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jackie
Top achievements
Rank 1
answered on 05 Jul 2017, 03:38 PM

Hi Ivan,

Thank you so much for your help, that works perfectly!

Tags
Scheduler
Asked by
Jackie
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Jackie
Top achievements
Rank 1
Share this question
or