Create event Fire 4 times

2 posts, 0 answers
  1. Abdalla
    Abdalla avatar
    8 posts
    Member since:
    May 2017

    Posted 11 May Link to this post

    I have Problem with UI schedule.when I try to enter new Meeting to the room the create event will fire 4 times 

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.CodeAnalysis.CSharp.Syntax;
    using TelerikScheduler.Entities;
    using TelerikScheduler.Services;
    using TelerikScheduler.ViewModels;
    using Kendo.Mvc.UI;
    using Kendo.Mvc.Extensions;
     
     
    namespace TelerikScheduler.Controllers
    {
        public class HomeController : Controller
        {
            private IMeetingData meetingData;
     
            public HomeController(IMeetingData meetingData)
            {
                this.meetingData = meetingData;
            }
     
            public IActionResult Index()
            {
                var model = new HomePageViewModel();
                model.Rooms = meetingData.GetAll();
     
     
                return View(model);
            }
     
            public virtual JsonResult ReadMeeting([DataSourceRequest] DataSourceRequest request)
            {
                return Json(meetingData.GetAll().ToDataSourceResult(request));
            }
     
            public virtual JsonResult DestroyMeeting([DataSourceRequest] DataSourceRequest request, Meeting meeting)
            {
                if (ModelState.IsValid)
                {
                   // meetingData.Delete(meeting);
                }
                return Json(new[] { meeting }.ToDataSourceResult(request, ModelState));
            }
     
            public virtual JsonResult CreateMeeting([DataSourceRequest] DataSourceRequest request, Meeting meeting)
            {
                if (ModelState.IsValid)
                {
                    meetingData.Insert(meeting, ModelState);
     
                }
                return Json(new[] { meeting }.ToDataSourceResult(request, ModelState));
            }
     
            public virtual JsonResult UpdateMeeting([DataSourceRequest] DataSourceRequest request, Meeting meeting)
            {
                if (ModelState.IsValid)
                {
                    //meetingData.Update(meeting);
                }
                return Json(new[] { meeting }.ToDataSourceResult(request, ModelState));
            }
     
     
            public IActionResult Error()
            {
                return View();
            }
        }
    }
    @using TelerikScheduler.Entities
    @using Kendo.Mvc.UI
    @using Microsoft.AspNetCore.Mvc.ModelBinding
    @model TelerikScheduler.ViewModels.HomePageViewModel
    <head>
        <title>Home</title>
    </head>
    <body>
        <h1>Welcome!</h1>
     
    @(Html.Kendo().Scheduler<Meeting>().Name("Meeting").Date(new DateTime(2017, 5, 13))
          .StartTime(new DateTime(2017, 5,13, 7, 00, 00))
          .Views(views=>{
              views.DayView();
              views.AgendaView();
          })
          .Height(600)
          .Timezone("Etc/UTC")
          .Group(group => { group.Resources("Rooms"); group.Date(true); })
          .Resources(resource =>
          {
              resource.Add(m => m.RoomId).Title("Room").Name("Rooms").DataTextField("Text").DataValueField("Value").DataColorField("Color").BindTo(new[] {
                  new { Text = "Meeting Room 101", Value = 1, Color = "#6eb3fa" },
                  new { Text = "Meeting Room 201", Value = 2, Color = "#f58a8a" }
              });
              resource.Add(m => m.Attendees)
                  .Title("Attendees")
                  .Multiple(true)
                  .DataTextField("Text")
                  .DataValueField("Value")
                  .DataColorField("Color")
                  .BindTo(new[] {
                      new { Text = "Alex", Value = 1, Color = "#f8a398" } ,
                      new { Text = "Bob", Value = 2, Color = "#51a0ed" } ,
                      new { Text = "Charlie", Value = 3, Color = "#56ca85" }
                  });
          }).DataSource(d => d
              .Model(m =>
              {
                  m.Id(f => f.RecordId);
                  m.Field(f => f.Title).DefaultValue("No title");
                  m.Field(f => f.Title).DefaultValue("No title");
              })
              .Read("ReadMeeting", "Home")
              .Create("CreateMeeting", "Home")
              .Destroy("DestroyMeeting", "Home")
              .Update("UpdateMeeting", "Home")
              ).BindTo(Model.Rooms).Deferred())
     
     
    @section scripts {
        @Html.Kendo().DeferredScripts()
    }
     
     
     
    </body>
    </html>

     

     

  2. Dimitar
    Admin
    Dimitar avatar
    175 posts

    Posted 16 May Link to this post

    Hello Abdalla,

    I am afraid I was not able to replicate the described issue.

    In the attached file (TelerikAspNetCoreAppScheduler.zip) you will find a basic setup for the Kendo Scheduler in ASP.NET Core, which I managed to setup by following the provided code sample. You can find the HTML markup in Views/Home/Index.cshtml and the Read and Create actions in Controllers/HomeController.cs.

    ​May I ask you to modify the above example, so that it reproduces the issue faced and send it back to us? This way I will be able to troubleshoot the problem and provide you with the most appropriate assistance for the case. 

    I am looking forward to hearing from you.

    Regards,
    Dimitar
    Telerik by Progress
    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.
Back to Top