How to Refresh Scheduler when NOT using JSON functionality?

8 posts, 1 answers
  1. Aaron
    Aaron avatar
    20 posts
    Member since:
    Jan 2015

    Posted 14 Nov 2015 Link to this post

    I am working on a C# MVC (5.2.2) App using Kendo.MVC 2015.3.930.545 (VS 2013 .NET 4.5.1) 

    Obviously I would like to be able to refresh/update the scheduler when changing the date(s).  I am not using the JSON-based functions as the demos use.  For my other Telerik controls, the same holds true.  That is, I use plain/vanilla server calls to the server instead.  I do capture some events using JS and do make AJAX calls to refresh data where/when applicable.  I would like to use this approach for the Scheduler but I need help w/this control.

    In this case, I would like to know how I can capture the change of dates.  I am not able to use the "Navigate" event nor .Data() for the .DataSource's .Read() method in my code (am I missing some lib? dll?):

     

    Here is my Scheduler control in my .cshtml file:

    @(Html.Kendo().Scheduler<EPIMS.Models.TaskViewModel>()
        .Name("scheduler")
        .Date(System.DateTime.Today)
        .StartTime(new DateTime(System.DateTime.Now.Year,System.DateTime.Now.Month,System.DateTime.Now.Day, 5, 00, 00))
        .Height(600)
        .Views(views =>
        {
            views.DayView(dayView => dayView.Selected(true));
            views.WorkWeekView();
            views.WeekView();
            views.MonthView();
        })
        .Timezone("Etc/UTC")
        .DataSource(d => d
            .ServerOperation(true)
            .Read("Details", "Inspections").Data()
            //.Read(read => read.Action("Details", "Inspections"))
            .Create("Create", "Inspections")
            .Destroy("Deactivate", "Inspections")
            .Update("Edit", "Inspections")
            .Events(e => 
            {
                e.Change("schedulerChange");
                e.Navigate
            })
        )
        .BindTo(Model)
    )

     The "Navigate" event is not available nor is the .Data() item for the .Read() method (for DataSource).

    I get this error @ runtime for the .Data() item:

    Compiler Error Message: CS1061: 'Kendo.Mvc.UI.Fluent.SchedulerAjaxDataSourceBuilder<EPIMS.Models.TaskViewModel>' does not contain a definition for 'Data' and no extension method 'Data' accepting a first argument of type 'Kendo.Mvc.UI.Fluent.SchedulerAjaxDataSourceBuilder<EPIMS.Models.TaskViewModel>' could be found (are you missing a using directive or an assembly reference?)

     

    and this error @ runtime for the e.Navigate event:

    Compiler Error Message: CS1061: 'Kendo.Mvc.UI.Fluent.DataSourceEventBuilder' does not contain a definition for 'Navigate' and no extension method 'Navigate' accepting a first argument of type 'Kendo.Mvc.UI.Fluent.DataSourceEventBuilder' could be found (are you missing a using directive or an assembly reference?)

     

    Am I using old API calls?  How can I capture the change of dates?

    Thanks,

     

     ​

  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 17 Nov 2015 Link to this post

    Hello Aaron,

    If you look closely in the official demo for server filtering you will notice that the "Data" method is available only after the "Action" method:

    .Read(read => read.Action("Read", "Home").Data("getAdditionalData"))

    Regards,
    Vladimir Iliev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Aaron
    Aaron avatar
    20 posts
    Member since:
    Jan 2015

    Posted 17 Nov 2015 in reply to Vladimir Iliev Link to this post

    I did look closely.  It just so happened that the code that I posted was not completely accurate. My apologies for that.

     Nonetheless, here is the actual line of code:

     

    Line 104: .DataSource(d => d

    Line 105: .ServerOperation(true)

    Line 106: .Read(read => read.Action("Details", "Inspections")).Data("getAdditionalData")

     

    And here is the error:

    Compiler Error Message: CS1061: 'Kendo.Mvc.UI.Fluent.SchedulerAjaxDataSourceBuilder<EPIMS.Models.TaskViewModel>' does not contain a definition for 'Data' and no extension method 'Data' accepting a first argument of type 'Kendo.Mvc.UI.Fluent.SchedulerAjaxDataSourceBuilder<EPIMS.Models.TaskViewModel>' could be found (are you missing a using directive or an assembly reference?)

  5. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 18 Nov 2015 Link to this post

    Hello Aaron,

    The issue is still related to the invalid configuration in the provided code:

    INVALID:
    .Read(read => read.Action("Details", "Inspections")).Data("getAdditionalData")

    VALID:
    .Read(read => read.Action("Details", "Inspections").Data("getAdditionalData"))

    Regards,
    Vladimir Iliev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Aaron
    Aaron avatar
    20 posts
    Member since:
    Jan 2015

    Posted 18 Nov 2015 in reply to Vladimir Iliev Link to this post

    Very well.  Thanks for that clarification.  An obvious oversight on my part.

    Now, there is still the matter of how to capture the change of dates?  I am trying to understand how the Scheduler's "Read" function works.  Is this the function that should be used to read from the DB (in the server) to refresh/update the Scheduler when the dates change?

  7. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 19 Nov 2015 Link to this post

    Hello,

    When you set the "ServerOperation" option of the Scheduler DataSource to "true", each time you navigate to different date or view the Scheduler will automatically call the "Read" action with the additional data from the custom "Data" function that you are using.

    Regards,
    Vladimir Iliev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  8. Aaron
    Aaron avatar
    20 posts
    Member since:
    Jan 2015

    Posted 22 Nov 2015 in reply to Vladimir Iliev Link to this post

    Thanks. I truly appreciate your time and attention.  A few more items howver.

    I am seeing the call back to the server's "Read" action on navigate (i.e .change of date).  It is worth noting that the "Read" action in this case is NOT defined/declared as "public virtual JsonResult" like in the demos.  Rather the action is defined/declared as "public ActionResult" which returns a View (the "Read" view to be specific).

    Upon initial load of the "Read" page, the task for the default date (i.e. today) IS displayed.

    However, the data is not getting refreshed when I navigate to a different date (i.e. yesterday) w/a scheduled task, nor when I navigate back to "Today".

    Additionally, when I click on the displayed task, I get a view (possible "Details") in a pop-up window.  However, when I click on the cancel button, the window is closed and the task is not longer visible in the "Read" view.

  9. Answer
    Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 23 Nov 2015 Link to this post

    Hello Aaron,

    Please note that the CRUD operation defined in the Scheduler DataSource should return JSON response and not views. That why I would suggest to define new action which to be different than the one used for loading the view and return JSON response as shown in our documentation and demos. 

    Regards,
    Vladimir Iliev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
Kendo UI is VS 2017 Ready