Conditional logic in reccurence event

5 posts, 0 answers
  1. Zoran
    Zoran avatar
    10 posts
    Member since:
    Sep 2012

    Posted 20 Nov 2015 Link to this post

    When I popup a recurrence event, it does not go back to the server where I have logic that is based on the start date before current date.

    How do I manipulate the Model that it creates from a recurrence event so that I can hide things based on the start date in my custom template?

    in my model I have isPassed but this is based on the first in the series and not the current event.. 

     

     

     

  2. Zoran
    Zoran avatar
    10 posts
    Member since:
    Sep 2012

    Posted 23 Nov 2015 Link to this post

    I tried this:

     Scheduler added an event edit handler:

     .Editable(editable =>
            {
                editable.TemplateName("CustomEditorTemplate");
            })
        .Events(e => e.Edit("edit_handler"))

        function edit_handler(e) {
            var dt = new Date();
            e.event.CanLog = e.event.Start < dt;
        };

    The value is changed in the data when I view it, but it does not seem to affect my template:

    If canlog is false I still see this:

    # if(CanLog){ #
    <div class="k-edit-label">
        @(Html.LabelFor(model => model.Title))
    </div>
    <div data-container-for="title" class="k-edit-field">
        @(Html.TextBoxFor(model => model.Title, new { @class = "k-textbox", @readonly = "readonly", data_bind = "value:title" }))
    </div>
    #}else{#

     

    Does the template get rendered before the edit event is called?

  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Zoran
    Zoran avatar
    10 posts
    Member since:
    Sep 2012

    Posted 23 Nov 2015 in reply to Zoran Link to this post

    Changed edit_handler:

     function edit_handler(e) {
            var dt = new Date();
            var canLog = e.event.Start < dt;
            e.event.set("CanLog", canLog);
        };

    Again I see the data changed, but it is not working in the custom view.

  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 24 Nov 2015 Link to this post

    Hello Zoran,

    Indeed, the editor template is rendered before edit event is triggered. This is done to ensure that the required HTML is available before bind the form to the edited event.

    If you would like to show/hide some parts of the editor, then you can do that easily using jQuery. Instead of using if/else logic, just wrap the HTML in div elements that you can show/hide. Once this is done, you can find the relevant elements and show/hide them accordingly:
    function edit_handler(e) {
      //look in e.container.
    }

    Regards,
    Georgi Krustev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Zoran
    Zoran avatar
    10 posts
    Member since:
    Sep 2012

    Posted 24 Nov 2015 Link to this post

    Thanks. Worked fine.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready