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

Kendo Scheduler Antiforgery token

1 Answer 140 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nanda
Top achievements
Rank 1
Nanda asked on 24 Mar 2021, 09:34 PM

I've a kendo scheduler which displays meetings. I'm passing some additional parameter to the read action method like start date, end date and some Boolean parameters, to fetch data. There is an antiforgery token in the view. How do I pass the antiforgery token with additional parameters to scheduler read method.

@(Html.Kendo().Scheduler<Kendo.Mvc.Examples.Models.Scheduler.Activity>()
.Name("scheduler")
.Height(600)
.EventTemplateId("event-template")
.Views(views =>
{
    views.DayView();
    views.WeekView(week =>
    {
        week.Selected(true);
    });
    views.WorkWeekView();
    views.MonthView();
    views.AgendaView();
})
.Resources(resource =>
{
    resource.Add(m => m.Attendee)
    .Title("Attendee")
    .DataTextField("Text")
    .DataValueField("Value")
    .DataColorField("Color")
    .BindTo(new[] {
        new { Text = "Jason", Value = 1, Color = "#eaf8ff" },
        new { Text = "Maddie", Value = 2, Color = "#fdfdf4" }
    });
})
.DataSource(d => d
    .Model(m =>
    {
        m.Id(f => f.ID);
        m.Field(f => f.Title).DefaultValue("No title");
        m.Field(f => f.Attendee).DefaultValue(1);
    })
    .Read("Overview_Read", "Scheduler").Data("additionalData")
     
)
)

1 Answer, 1 is accepted

Sort by
0
Stoyan
Telerik team
answered on 29 Mar 2021, 02:56 PM

Hi Nanda,
Thank you for your inquiry.

You are on the right track. In a script define the additionalData function and return the antiforgery token and the additional parameter to be sent to the Controller.

function additionalData() {
        return {
            __RequestVerificationToken: kendo.antiForgeryTokens().__RequestVerificationToken,
            additionalParam: "example";
        };
    }
 I hope this helps. Please let me know, if you have further questions.

 

Regards,
Stoyan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
Nanda
Top achievements
Rank 1
Answers by
Stoyan
Telerik team
Share this question
or