Multiple Resource Issues

4 posts, 0 answers
  1. Chris
    Chris avatar
    19 posts
    Member since:
    Feb 2015

    Posted 10 Mar 2015 Link to this post

    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




























































































































































  2. Chris
    Chris avatar
    19 posts
    Member since:
    Feb 2015

    Posted 10 Mar 2015 Link to this post

    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.
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Chris
    Chris avatar
    19 posts
    Member since:
    Feb 2015

    Posted 11 Mar 2015 Link to this post

    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>
  5. Chris
    Chris avatar
    19 posts
    Member since:
    Feb 2015

    Posted 11 Mar 2015 Link to this post

    Added:

     .ValuePrimitive(true)

    to the multiselect in the custom editor and now everything seems to be working.
Back to Top
UI for ASP.NET MVC is VS 2017 Ready