7 Answers, 1 is accepted
From the point of view of the scheduler, the Razor page is no different than a regular view+controller - its CRUD operations need to point to the correct URLs where the controller will receive them. Those URLs are different in a Razor page than with a regular controller and that's all you need to take into account.
While we don't have a sample ready for the scheduler, we have two for the grid and the concept is the same:
- https://github.com/telerik/ui-for-aspnet-core-examples/tree/master/grid/razor-pages-crud
- https://github.com/telerik/ui-for-aspnet-core-examples/tree/master/grid/razor-pages-custom-datasource-date-editing
On using EF - this is entirely up to the project and a sample that fits yours is highly specific. I would recommend you examine the arguments the handlers receive so you can see how they fit into your data access logic. The standard MVC Core demos we have also use a similar approach and you can download and inspect/run/modify them in Visual Studio if you like. For example, this one, where you can also see sample signatures of the CRUD operations methods: https://demos.telerik.com/aspnet-core/scheduler/index.
Regards,
Marin Bratanov
Progress Telerik
Hi Marin
I have look into the sample but on the scheduler, I got 400 bad request when reading data.
My reading URL look's like this .Read(r => r.Url("?handler=Read")) which is valid because if I do a Ajax post, it does fired the OnPostRead method. but not when scheduler trying to read. Can you help on this? thanks
Hi Marin
More detail coding below
@(Html.Kendo().Scheduler<
Caravel.Models.KenoSalesCalendarModel
>()
.Name("scheduler")
.Date(DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Monday))
.StartTime(new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 8, 00, 00))
.Height(600)
.Views(views =>
{
views.DayView();
views.WorkWeekView(workWeekView =>
{
workWeekView.Selected(true);
});
views.WeekView();
views.MonthView();
views.AgendaView();
views.TimelineView();
})
.Timezone("Asia/Singapore")
.Resources(resource =>
{
resource.Add(m => m.OwnerID)
.Title("Owner")
.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
.Events(e => e.Error("onError"))
.Model(m =>
{
m.Id(f => f.TaskID);
m.Field(f => f.Title).DefaultValue("No title");
m.Field(f => f.OwnerID).DefaultValue(1);
m.RecurrenceId(f => f.RecurrenceID);
})
.Read(r => r.Url("?handler=Read").Type(HttpVerbs.Post))
.Filter(filters =>
{
filters.Add(model => model.OwnerID).IsEqualTo(1).Or().IsEqualTo(2);
})
)
)
I am attaching here a sample with razor pages I made for you that seems to work fine for me. Could you compare against it to see what's the difference causing the issue? If you still can't resolve it, please modify my sample to showcase the issue so I can have a better look at it.
Regards,
Marin Bratanov
Progress Telerik