WRONG ARGUMENTS IN LOAD ON DEMAND FUNCTION

I have a problem with loading on demand: when GetData is called the string arguments are set to null and the date is set to the earlier date possible. Which arguments should I use? Is there something wrong in my html code?

 public JsonResult GetData(string CurrentView, DateTime CurrentDate, string CurrentAction)
        {
            DateTime a = GetFirstDayOfWeek(CurrentDate);
            DateTime b = GetLastDayOfWeek(CurrentDate);
            var data = from appoint in _context.Appointments
                       where displayWho.Contains(appoint.OwnerId) &&
                             appoint.StartTime > a && appoint.EndTime < b
                       select appoint;
            var x = data.ToList();
            return Json(x);
        }


<ej-schedule id="Schedule1" width="100%" height="525px" current-date="DateTime.Now" read-only="false" enable-load-on-demand="true">
    <e-resources>
        <e-resource field="OwnerId" title="Owner" name="Owners" allow-multiple="true">
            <e-resource-settings datasource="@ViewBag.Owners" text="text" id="id" color="Color">
            </e-resource-settings>
        </e-resource>
    </e-resources>
    <e-appointment-settings apply-time-offset="false" id='"Id"' subject='"Subject"' start-time='"StartTime"' end-time='"EndTime"' description='"Description"' all-day='"AllDay"' recurrence='"Recurrence"' recurrence-rule='"RecurrenceRule"'>
        <e-datamanager url="/Home/GetData"  crud-url="Home/Batch" adaptor="UrlAdaptor"></e-datamanager>
    </e-appointment-settings>
</ej-schedule>


1 Reply

NR Nevitha Ravi Syncfusion Team April 4, 2018 12:48 PM UTC

Hi Giorgio, 

Thank you for contacting Syncfusion Support. 

With the ASP.NET Core projects, the default arguments such as current view, current action and current date can be accessed at the server-end by adding the [FromBody] attribute initially as highlighted below. In your shared code, arguments are passed directly which could be suspected to be the cause of the reported problem. We have prepared a working sample for your reference which can be downloaded from the following location. 

public BatchDataResult GetData([FromBody] MyPostModel post) 
        { 
 
            var data = FilterAppointment(post.CurrentDate, post.CurrentAction, post.CurrentView); 
            BatchDataResult result = new BatchDataResult(); 
            result.result = data; 
            result.count = _context.DefaultSchedule.ToList().Count > 0 ? _context.DefaultSchedule.ToList().Max(p => p.Id) : 1; 
            return result; 
        } 
        public class MyPostModel 
        { 
            public DateTime CurrentDate { get; set; } 
            public string CurrentView { get; set; } 
            public string CurrentAction { get; set; } 
        } 
        public class BatchDataResult 
        { 
            public Object result { get; set; } 
            public int count { get; set; } 
        } 


Kindly try out the above sample and let us know if it works on your end and also if you need any further assistance on this. 

Regards, 
Nevitha. 


Loader.
Up arrow icon