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

GetResources gets called without me being able what user is logged in

7 Answers 133 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
sta
Top achievements
Rank 1
sta asked on 06 Apr 2012, 02:09 PM
Dear Telerik.

I was following our examples of RadScheduler with Teachers and Students as ResourceTypes. I build dynamic resource types per user (every user can CRUD their resource types). For this to happen I obviously need to store user id inside every resource type. 
I use web service approach (this is the only option if you work with MVC) with ResourcePopulationMode="ServerSide".
In my public class SchedulerProvider : SchedulerProviderBase

public override IEnumerable<Appointment> GetAppointments(ISchedulerInfo schedulerInfo)
    {
      var membershipUser = Membership.GetUser();
membershipUser is the user that is currently logged in user, which is expected.

However, in here in the same class:
    public override IDictionary<ResourceTypeIEnumerable<Resource>> GetResources(ISchedulerInfo schedulerInfo)
    {
      var membershipUser = Membership.GetUser();
memebrshipUser is ALWAYS NULL regardless if somebody is logged in or not.

It seems to me that its a different instance of the same class, which I cannot figure out why.
This is preventing me from being able to retrieve only relevant resource types and resources for currently logged in user.
Can you please guide me through what should be done here (how to get the resource types for currently logged in user inside GetResources), and if I am using RadScheduler control  the right way in MVC environment at all.

Thank you very much in advance!

7 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 09 Apr 2012, 12:22 PM
Hello Sta,

Yes, RadScheduler should be populated using a Web Service when integrating the control in MVC.

If you need to filter appointments based on the current user, you can send additional information to the provider (scroll down to the section on using web-service data binding). The same technique is used in the Web Service binding demo to filter appointments based on a resource value. You can download a stand-alon sample from this code library entry.

Regards, Peter
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
sta
Top achievements
Rank 1
answered on 09 Apr 2012, 02:13 PM
Hi Peter,

Thanks for prompt response. This is a great example. The only problem is that I have to use GetResources rather than GetAppointments method. And I cannot populate additional information in GetResources method since RadScheduler1_ResourcesPopulating doesn't get called on client if I use ResourcePopulationMode="ServerSide" . And I cannot use ClientSide because ServerSide is the only way to enable Resource Grouping as mentioned here.

If you can explain where on the way from client to server can I pass User Id (or User Name or anything to infer user identity) and how.

 I only see 3 options (2 of them aren't working in my tests, one is terribly ugly spaghetti code):
  1. in RadScheduler1_ResourcesPopulating on client (that doesn't get called because of serverside population mode), or
  2. in web server service class (really really ugly code - would hate to have this kind of code in my project and not sure it will work) or 
  3. server side (didn't work for me as I mentioned in my initial posting - Membership.GetUser is NULL)

Please let me know (or the best - show some example or working project) how to send user id (UserId or UserName or MembershipUser - something I can infer user id from) for GetResources method (not GetAppointments one). They seem to be called on different threads and the example you providing for GetAppointments above doesn't work for GetResources (which I am looking for) unfortunately.

Thank you very much in advance!
0
Peter
Telerik team
answered on 09 Apr 2012, 02:45 PM

Good point! Since ResourcePopulationMode="ServerSide", this means we can use the server-side ResourcesPopulating event of RadScheduler to pass the extra info to the provider. Here is a video capture that illustrates the approach - http://screencast.com/t/56ZKrwi8fYfl

Greetings,
Peter
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
sta
Top achievements
Rank 1
answered on 09 Apr 2012, 03:22 PM
Hi Peter,
Excellent screen cast. Thanks!
I am in MVC environment. (no web forms and no code behind to capture resource populating event of RadScheduler).
Am I missing something?
Thanks.
0
Peter
Telerik team
answered on 09 Apr 2012, 04:35 PM

You are right. I completely missed that 'little' detail in MVC - no server-side event handling. Now that makes things much more difficult. I will research if a workaround could be possible and contact you again with my findings.

All the best,
Peter
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
sta
Top achievements
Rank 1
answered on 09 Apr 2012, 04:53 PM
Greatly appreciate it, Peter. Waiting for your response ...
0
Peter
Telerik team
answered on 13 Apr 2012, 09:03 AM

It looks like this scenario is not supported in MVC environment, or at least I wasn't able to find a good workaround.

Regards,
Peter
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Scheduler
Asked by
sta
Top achievements
Rank 1
Answers by
Peter
Telerik team
sta
Top achievements
Rank 1
Share this question
or