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

Kendo scheduler new event set attendees onload

3 Answers 184 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Anamika
Top achievements
Rank 1
Anamika asked on 30 May 2017, 11:57 AM

Hello,

 

i am using custom template for Event add/edit with Kendo Scheduler. I am trying to presenect attendees when user clicks to create new Event. Here is my Scheduler edit event

 function scheduler_edit(e) {
        var usrName = "@HttpContext.Current.User.Identity.Name";
      
        if ( e.event.CanOpen) {
            e.preventDefault();
        }
        var eventid = e.event.id;
    
        if (e.event.isNew()) {
           
            var rootDir = "@Url.Content("~/")";
                  
                    $.ajax({
                        url: rootDir + "Objekt/LoadAdress",
                        cache: false,
                        async: false,
                        data: {
                            strSelectedObjectID: objectid
                        },
                        success: function (data) {
                            if (data.result == "Error") {
                                alert(data.message);
                            } else {
                
                                var value = usrName.split(",");
                                e.event.set("ObjectDesc", desc);
                                e.event.set("ObjectID", objectid);
                                e.event.set("LetterHead", data.LetterHead);
                                e.event.set("Attendees", usrName);
                            }
                        }
                    });
                }
            }
        }
    }

The objectID and rest of fields Comes populated. Only Attendees is blank.

The customtemplate has the attendees multiselect as

<div data-container-for="Attendees" class="k-edit-field">
@(Html.Kendo().MultiSelectFor(model => model.Attendees)
.Name("attendies")
.HtmlAttributes(new { data_bind = "value:Attendees" ,style = "width: 300px"})
.DataTextField("LoginName")
.DataValueField("LoginName")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetCustomers", "Scheduler");
});
})
.Events(e => { e.DataBound("data_bound"); })
.Value((List<Object>)ViewBag.SelectedUser)
.ValuePrimitive(true)
.TagTemplate("<span class='k-scheduler-mark' style='background-color:\\#= data.Color?Color:'' \\#'></span>\\#=LoginName\\#")
.ItemTemplate("<span class='k-scheduler-mark' style='background-color:\\#= data.Color?Color:'' \\#'></span>\\#=LoginName\\#")
)
<span class="k-invalid-msg" data-for="Attendees"></span>
</div>

 

Thanks

 

Anamika

3 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 01 Jun 2017, 10:38 AM

Hello Anamika,

The described requirement is typically done by using the Resources option of the Scheduler, which will enable you to setup a DataSource for the external resource to be bound to the events. You can check out this demo: http://demos.telerik.com/aspnet-mvc/scheduler/resources

As for the solution you have, I am unable to properly examine what might the reason for the issue you experience. I see that the MVC wrapper is set up with ValuePrimitive enabled. Try usoing the data-value-primitive attribute instead (https://demos.telerik.com/kendo-ui/multiselect/mvvm and http://docs.telerik.com/kendo-ui/framework/mvvm/bindings/value#view-model-fields-with-value-field-of-primitive-value). Also, make sure that the value primitive option is indeed needed for the case. If the Attendees fields returns an array of non-primitive object items, then, you most probably do not need the option. 

If you still have some difficulties with the case, please, provide a simple, locally runnable project so that I can take a better look at the case and examine it closely.

Regards,
Ianko
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
Anamika
Top achievements
Rank 1
answered on 06 Jun 2017, 10:00 AM

Hello Lanko,

 

Unfortunately nothing helped. I am grouping the Scheduler by date and a resource which is list of attendies as well. Could that be the Problem?

 

Thanks

 

Anamika

0
Ianko
Telerik team
answered on 07 Jun 2017, 04:48 AM

Hello Anamika,

I am afraid I am unable to exactly understand how grouping by date and resource could be somehow a possible reason for the described behavior. Possibly, it might be related to the exact approach Scheduler is used with the data bound.  This, however, with a live application it is difficult to be properly investigated.

It would be very helpful if you can isolate the case in a locally runnable example so that we can properly examine the code and the scenario, and be able to properly define the reason for the behavior and help you out on a possible resolution.

Regards,
Ianko
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.
Tags
Scheduler
Asked by
Anamika
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Anamika
Top achievements
Rank 1
Share this question
or