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

Multiple Resource Issues

3 Answers 143 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 10 Mar 2015, 06:52 PM
Using a standard scheduler I am attempting to assign multiple resources. However, on submit I am getting a javascript alert error telling me the "someNumber" is invalid, where some number is the Datavalue for resource RegionRes. ("1" is invalid, "2" is invalid. etc)
 
The following things happen:

The record is processed and inserting into the database.
The edit form does not close.
Upon cancelling out of the edit form the event does not appear on the schedule.
Upon refreshing no events will appear on the schedule.

However, deleting the the offending record(s) from the join table and refreshing the calendar all events appear again.

Here is the scheduler:
@(Html.Kendo().Scheduler<SchedulerViewModel>()
        .Name("scheduler")
        .Views(views =>
            {
                views.DayView();
                views.WeekView();
                views.MonthView(monthView => monthView.Selected(true));
            })
        .Resources(resource =>
                    {
                        resource.Add(r => r.RegionIds)
                            .Name("RegionsResource")
                            .Title("RegionsRes")
                            .DataTextField("RegionName")
                            .DataValueField("RegionId")
                            .Multiple(true)
                            .DataSource(source =>
                            {
                                source.Read(read => { read.Action("RegionDropDownList", "DropDownList"); });
                            });
 
                        resource.Add(v => v.VenueId)
                            .Name("VenuesResource")
                            .Title("VenueRes")
                            .DataTextField("VenueName")
                            .DataValueField("VenueId")
                            .BindTo((IEnumerable<VenueViewModel_DDL>)ViewData["Venues"]);
                    }
 
        )
        .DataSource(d => d.Model(m =>
            {
                m.Id(f => f.EventId);
                m.Field(f => f.Title).DefaultValue("No title");
                m.RecurrenceId(f => f.RecurrenceID);
                m.Field(f => f.IsAllDay).DefaultValue(false);
            })
            .Read("Read", "Scheduler")
            .Create("Create", "Scheduler")
            .Destroy("Destroy", "Scheduler")
            .Update("Update", "Scheduler")
            .Events(e => e.Error("error_handler"))
        )
        .Editable(true)
    )

I have also tried a bindto using viewdata to no avail.

It is just very odd that it will display the multiselect for edit and insert the event into the database but not display the event.

As usual any help would be appreciated.

Thanks,
Chris




























































































































































3 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 10 Mar 2015, 11:19 PM
Figured it out. Putting it example terms. Using the meeting example. I was passing the ICollection<MeetingAttendee> in my view model instead of just the IEnumberable<int> of Attendees. What was throwing me and making me this it was something front end related is that no errors were raised until after the record had been inserted.
0
Chris
Top achievements
Rank 1
answered on 11 Mar 2015, 06:27 PM
I spoke a little to soon on it being resolved. I works when being used as a resource in a standard calendar/editor. However, it does not work when using a multiselect in a custom editor template.

Relevant code for standard editor:
.Resources(resource =>
                    {
                        resource.Add(r => r.RegionIds)
                            .Name("RegionsResource")
                            .Title("RegionsRes")
                            .DataTextField("RegionName")
                            .DataValueField("RegionId")
                            .Multiple(true)
                            .DataSource(source =>
                                {
                                    source.Read(read => { read.Action("RegionDropDownList", "DropDownList"); });
                                });
 
                        resource.Add(v => v.VenueId)
                            .Name("VenuesResource")
                            .Title("VenueRes")
                            .DataTextField("VenueName")
                            .DataValueField("VenueId")
                            .DataSource(source =>
                                {
                                    source.Read(read => { read.Action("VenueDropDownList", "DropDownList"); });
                                });
                    }
 
        )
        .DataSource(d => d.Model(m =>
            {
                m.Id(f => f.EventId);
                m.Field(f => f.Title).DefaultValue("No title");
                m.RecurrenceId(f => f.RecurrenceID);
                m.Field(f => f.IsAllDay).DefaultValue(false);
                m.Field(f => f.RegionIds);
            })
            .Read("Read", "Scheduler")
            .Create("Create", "Scheduler")
            .Destroy("Destroy", "Scheduler")
            .Update("Update", "Scheduler")
            .Events(e => e.Error("error_handler"))
        )
Relevant code for the customeditor:
<div data-container-for="RegionIds" class="k-edit-field">
 
    @(Html.Kendo().MultiSelectFor(model => model.RegionIds)
            .Name("RegionIds")
            .HtmlAttributes(new { data_bind = "value:regionIds", style = "width: 300px"})
            .Placeholder("Select A Region")
            .DataTextField("RegionName")
            .DataValueField("RegionId")
            .DataSource(source =>
                {
                    source.Read(read => { read.Action("RegionDropDownList", "DropDownList"); });
                })
 
)
</div>
0
Chris
Top achievements
Rank 1
answered on 11 Mar 2015, 06:52 PM
Added:

 .ValuePrimitive(true)

to the multiselect in the custom editor and now everything seems to be working.
Tags
Scheduler
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Share this question
or