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

Conditional logic in reccurence event

4 Answers 54 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Zoran
Top achievements
Rank 1
Zoran asked on 20 Nov 2015, 06:59 PM

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.. 

 

 

 

4 Answers, 1 is accepted

Sort by
0
Zoran
Top achievements
Rank 1
answered on 23 Nov 2015, 03:15 PM

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?

0
Zoran
Top achievements
Rank 1
answered on 23 Nov 2015, 03:50 PM

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.

0
Georgi Krustev
Telerik team
answered on 24 Nov 2015, 10:44 AM
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
0
Zoran
Top achievements
Rank 1
answered on 24 Nov 2015, 04:48 PM
Thanks. Worked fine.
Tags
Scheduler
Asked by
Zoran
Top achievements
Rank 1
Answers by
Zoran
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or