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

Schedule Resources datasource is not updating

10 Answers 557 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 2
Alan asked on 02 Jan 2014, 05:39 PM
My application is in ASP.NET MVC 5 using Razor views and remote data stored in a SQL Server database.

I have a Kendo Grid which contains a list of Users. This list of users then becomes a resource list in a Kendo Scheduler.

The problem I have is when I add a new user to the grid, open the scheduler then open the task editor the new user does not appear in the resource list; the new user appears in the grid and is created in the database. If I exit the application and then re-run it the user is present in the scheduler resource dropdown. In other words the resource datasource is not being refreshed when the scheduler is displayed.

Now the complication:
The user grid sits in a Partial View: The grid has a toolbar template consisting of a 'Create New User' button(editing is via a popup)  and a Kendo button which calls a script to display a Kendo Window; the window is model and configured via .LoadContentsFrom to display the scheduler view.

I have tried several methods, found on this forum, to get the scheduler resources to update before opening the task editor without success.

Your help would be appreciated

Alan

10 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 06 Jan 2014, 10:16 AM
Hello Alan,

Judging from the provided description, in your case the way the scheduler resource DataSource should be refreshed depends on your scenario exact implementation. Therefore, could you please provide runnable sample application which demonstrates your scenario. This will allow us to get better understanding about your case and provide you with more to the point answer. 

Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alan
Top achievements
Rank 2
answered on 07 Jan 2014, 12:18 PM
Hi Rosen,
My apologies for the delay in responding. I have attached a project which demonstrates my implementation and the issue

Thanks

Alan
0
Rosen
Telerik team
answered on 07 Jan 2014, 01:28 PM
Hi Alan, 

I have looked at the sample you have provided and it seems that the described issue is not related to our widgets but to the logic responsible for saving and retrieving the data from the backend. It seems that when the scheduler resources are retrieved the DataContext is not yet updated with the newly created data and it still returns the older state of the data. Modifying the code responsible for creating the DbContext seems to fix the issue in question:

public class SchedulerDemoController : Controller
{
    ApplicationDbContext _db;
 
    public SchedulerDemoController()
    {
       _db = new ApplicationDbContext();
    }
 
   //......
 }


Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alan
Top achievements
Rank 2
answered on 07 Jan 2014, 03:50 PM
Hi Rosen,

I have just moved the dbContext instantiation into the controller constructor but it has made no difference to the result.

The resource dropdown is still not being populated with the newly created person until I close and re-run the application.
I need a way to ensure the resource list is refreshed when the schedule window is opened so it picks up new users in the database. At the moment it seems to be loaded when the grid view, where the kendo window is declared, is loaded. instead of when the window is opened.

Thanks for your help

Alan
0
Rosen
Telerik team
answered on 07 Jan 2014, 04:28 PM
Hello Alan,

Indeed, you are correct the behavior I was observing seems to be due to sample project misbehaving when run locally on my machine. Thus, please disregard my previous suggestion.

However, you may try to refresh the content of the window by calling its refresh method prior to opening:

function ShowSchedule(e) {
    e.preventDefault();
    $("#ScheduleWindow").data("kendoWindow").refresh().maximize().open();
}


Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alan
Top achievements
Rank 2
answered on 07 Jan 2014, 05:30 PM
Hi Rosen,
Thank you again for your help;

Still no luck with this; Below is the Fiddler output when using refresh(). 

As you can see the Scheduler View is loaded at the same time as the user grid view. When I click on the button to display the scheduler I do get a new call to the Scheduler Action and a new read of the tasks but the UserResource_Read action is not called again to pick up the new user created just before.

200 HTTP localhost:39586 /
200 HTTP localhost:39586 /__browserLink/requestData/49dcc69baadc4500a1f120477b42ae34
200 HTTP localhost:39586 /SchedulerDemo
200 HTTP localhost:39586 /SchedulerDemo/ServiceUser_Read
200 HTTP localhost:39586 /SchedulerDemo/Scheduler
200 HTTP localhost:39586 /__browserLink/requestData/15437a4f46574251b7ce9fd298b3478b
200 HTTP localhost:39586 /SchedulerDemo/UserResource_Read
200 HTTP localhost:39586 /SchedulerDemo/Tasks_Read
NOTE: New User Added
200 HTTP localhost:39586 /SchedulerDemo/ServiceUser_Create
NOTE: Schedule button clicked
200 HTTP localhost:39586 /SchedulerDemo/Scheduler
200 HTTP localhost:39586 /SchedulerDemo/Tasks_Read
0
Rosen
Telerik team
answered on 08 Jan 2014, 07:20 AM
Hello Alan,

I have prepared a short video which captures the sample project behavior before and after applying the suggested change. Please take a look maybe I'm missing something obvious.

Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alan
Top achievements
Rank 2
answered on 08 Jan 2014, 11:01 AM
Hi Rosen,
Thank you again for your help.

It would seem this is a browser related issue - my development is in IE11

I noticed you are using Chrome so I ran the project in Firefox and Chrome.

With the refresh() added when I clicked the Schedule button directly after adding a new user I got an error from $("#ScheduleWindow").data("kendoWindow").refresh().maximize().open();
0x800a138f - JavaScript runtime error: Unable to get property 'open' of undefined or null reference
Just in case anyone else hits this error in VS2013 which uses jquery-1.10.2 it is fixed by adding jquery-migrate-1.2.1.min.js.

So all is working correctly in Firefox and Chrome but not IE11 which still does not reload the resources.

I would appreciate it if you could test this in IE

Again many thanks

Alan
0
Accepted
Rosen
Telerik team
answered on 08 Jan 2014, 12:50 PM
Hello Alan,

I'm afraid that IE11 seems to behave the same as Chrome on my end. Please take a look at this short video.

However, maybe you have enabled the IE caching. In which case you may consider changing the type of the resources request to be POST as this should force the browser to issue new request every time:

.Resources(resources => resources.Add(r =>
           r.OwnerID)
           .Title("User")
           .DataTextField("Name")
           .DataValueField("UserId")
           .DataColorField("Colour")
           .DataSource(ds => ds.Read(read => read.Action("UserResource_Read", "SchedulerDemo").Type(HttpVerbs.Post))))


Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alan
Top achievements
Rank 2
answered on 08 Jan 2014, 01:47 PM
Rosen,

Many thanks for that; as you say IE Caching is most likely to blame.
Your post workaround appears to have worked

Again many thanks for your time and effort with this.

Alan

Tags
Scheduler
Asked by
Alan
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Alan
Top achievements
Rank 2
Share this question
or