'Syncfusion EJ2(EJS) Schedule. Cannot populate from JSON
I'm having trouble data binding JSON to the SyncFusion Schedule. Referring to this article In my .cshtml I have this
<div class="col control-section">
<div class="content-wrapper">
@(Html.EJS().Schedule("schedule")
.Width("100%")
.Height("650px")
.EventRendered("onEventRendered")
//.EventSettings(new ScheduleEventSettings { DataSource = ViewBag.datasource })
.EventSettings(e => e.DataSource(d => d.Url("Home/GetAppointmentData").CrudUrl("Home/SaveAppointmentData").Adaptor("UrlAdaptor").CrossDomain(true)))
.SelectedDate(DateTime.Now).Render()
)
</div>
</div>
Home/GetAppointmentData generates the JSON as in the attached file.
public class AppointmentData
{
public int Id { get; set; }
public string Subject { get; set; }
public string Location { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public string CategoryColor { get; set; }
}
In the browser console, I get this error.
Uncaught SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at Object.parseJson (ej2.min.js:10)
at e.onSuccess (ej2.min.js:10)
at e.successHandler (ej2.min.js:10)
at e.stateChange (ej2.min.js:10)
at XMLHttpRequest.t.httpRequest.onreadystatechange (ej2.min.js:10)
I have run the content through several JSON parsers online and all of them show no error with the content. What am I missing, please?
There appears to be no format of legal JSON that will get past this error, can anyone help me
Just as I was starting to make good progress working out how the scheduler actually works because the documentation is poor, incorrect or inconsistent (or all of these).
Solution 1:[1]
Use the below code example and for the same below sample is prepared for your reference.
EventSettings(e => e.DataSource(d => d.Url("/Home/GetData").CrudUrl("/Home/UpdateData").Adaptor("UrlAdaptor").CrossDomain(true)))
https://www.syncfusion.com/downloads/support/directtrac/general/ze/ScheduleCRUD308652568
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Dharman |