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

3 posts, 1 answers
  1. Jackie
    Jackie avatar
    17 posts
    Member since:
    Jun 2017

    Posted 30 Jun 2017 Link to this post

    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. Answer
    Ivan Danchev
    Admin
    Ivan Danchev avatar
    2132 posts

    Posted 03 Jul 2017 Link to this post

    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.
  3. Jackie
    Jackie avatar
    17 posts
    Member since:
    Jun 2017

    Posted 05 Jul 2017 Link to this post

    Hi Ivan,

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

Back to Top