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

Client Binding & DbSchedulerProviderBase

7 Answers 270 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Axe
Top achievements
Rank 1
Axe asked on 19 Mar 2009, 02:11 AM
I was playing around with the new bits and wanted to try to use WCF Service using DbSchedulerProviderBase.
I kept getting errors on the DbSchedulerProviderBase method LoadResources when it tries to add a Resource to the appointment.
I thought I must had done something wrong so I open the Quick Start Examples in Visual Studio and altered the example http://demos.telerik.com/aspnet-ajax/scheduler/examples/wcf/defaultcs.aspx to use the MyDbSchedulerProvider instead by passing in the name of provider from web.config:
    private WebServiceAppointmentController Controller  
    {  
        get 
        {  
            if (_controller == null)  
            {  
                //_controller =  
                //    new WebServiceAppointmentController(  
                //        new XmlSchedulerProvider(HttpContext.Current.Server.MapPath("~/App_Data/Appointments_Outlook.xml"),   
                //            false));  
 
                _controller = new WebServiceAppointmentController("ReadOnlySchedulerData");  
            }  
            return _controller;  
        }  
    }  
 

I then ran the page and got the same error on the method below on line 16:
        private void LoadResources(Appointment apt)  
        {  
 
            using (DbConnection conn = OpenConnection())  
            {  
                DbCommand cmd = DbFactory.CreateCommand();  
                cmd.Connection = conn;  
 
                cmd.Parameters.Add(CreateParameter("@ClassID", apt.ID));  
                cmd.CommandText = "SELECT [TeacherID] FROM [DbProvider_Classes] WHERE [ClassID] = @ClassID AND [TeacherID] IS NOT NULL";  
                using (DbDataReader reader = cmd.ExecuteReader())  
                {  
                    if (reader.Read())  
                    {  
                        Resource teacher = apt.Owner.Resources.GetResource("Teacher", reader["TeacherID"]);  
                        apt.Resources.Add(teacher);  
                    }  
                }  
 
                cmd.Parameters.Clear();  
                cmd.Parameters.Add(CreateParameter("@ClassID", apt.ID));  
                cmd.CommandText = "SELECT [StudentID] FROM [DbProvider_ClassStudents] WHERE [ClassID] = @ClassID";  
                using (DbDataReader reader = cmd.ExecuteReader())  
                {  
                    while (reader.Read())  
                    {  
                        Resource student = apt.Owner.Resources.GetResource("Student", reader["StudentID"]);  
                        apt.Resources.Add(student);  
                    }  
                }  
            }  
        }  
 

The method GetResource returns null.

Can you check it out and let us know how to implement client binding from a database.

BTW I added a check for null and it works but of course there is no resources so it is specifically relating to how to load resources.
We can load resources from XML so I guess we just need to change the implementation of DbSchedulerProviderBase unless I have really missed somthing here.

Regards
Axe

7 Answers, 1 is accepted

Sort by
0
Axe
Top achievements
Rank 1
answered on 19 Mar 2009, 12:55 PM
I just checked out the WCF demo http://demos.telerik.com/aspnet-ajax/scheduler/examples/wcf/defaultcs.aspx and it appears that it does not render resources. is this correct or am I missing somthing? The data source file Appointments_Outlook.xml appears to have resources and when I set break points on the service the methods were returning the resources but just not rendering on the form.

Any suggestions?
0
Atanas Korchev
Telerik team
answered on 20 Mar 2009, 12:19 PM
Hi Axe,

Client-side grouping has not been implemented in the Q1 2009 release. We will do our best to provide the most commonly used grouped views for the upcoming service pack. Which grouped views do you use the most?

Regards,
Albert
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Axe
Top achievements
Rank 1
answered on 21 Mar 2009, 08:56 AM
I've only just started looking at this control when I heard about client side binding (mainly cause of MVC) so I have no experience with it other than playing around with a few ideas.
When you say grouped views are you reffering to this example - http://demos.telerik.com/aspnet-ajax/scheduler/examples/resourcegrouping/defaultcs.aspx

My original post was to find out how to get DbSchedulerProviderBase to work with web services particularly the LoadResources method. It works fine with xml. I checked firebug and I see 2 calls made. 1 for GetAppointments and 1 for GetResources. The data is being returned for both calls. But using the DbSchedulerProviderBase I get errors as I mentioned above. After finding out the data is returned I see that controls are not rendered for these resources any way. i played with templates and noticed that the advanced templates will render but not the inline templates. If I can make some advanced templates can I take the data from the 2 service calls and bind controls? Then can we call a client method to insert/edit. I checked the docs and noticed there are a few events fired relating to web services - http://www.telerik.com/help/aspnet-ajax/schedule_clientsideevents.html Can we get to any of the data in any of those events to use advanced templates? I wanted to use Visual Studio debugger to investigate what was in each of the events but for some reason Visual Studio is not hitting javascript breakpoints at the moment.

In a nutshell what would be cool is if you could create/expose a client api so we could do most of the stuff you can do with the control server side. Most use case scenarios I can think of would require at least the use of one resource so I think it's essential to have some control over this when client side binding. Templates are also important so we can customize the look and behavior. This is all in the context of client side and it's really only important because of MVC.

Regards
Axe

0
T. Tsonev
Telerik team
answered on 24 Mar 2009, 03:56 PM
Hello Axe,

Thank you for your feedback. The web-service data binding is still far from mature and your input is very important to us.

You are correct, the example you mention demonstrates the resource grouping feature.

As for the resources there are a few things that I need to clarify. First, the DbSchedulerProvider sample has a bug that prevents it from working with web service data binding. It's easy enough to fix though. The problem is this line:

Resource student = apt.Owner.Resources.GetResource("Student", reader["StudentID"]); 

In a web service scenario the RadScheduler instance (Owner) might not be exactly what you would expect. Because the web service has no means to obtain a reference to the calling RadScheduler you get an empty scheduler on each call. It's there just because our provider interface requires it. We'll take care of that in future versions and we'll replace it with a proper set of interfaces.

The solution is to instead create a new Resource instance fresh from the database. I'm attaching a sample project that includes this fix.

We actually support resource editing out of the box. This can be done in the advanced form, but for this to work the resources must be available on the server. We can actually pull them from the web service by using a property on the RadScheduler:

<telerik:RadScheduler ...>
    <WebServiceSettings ResourcePopulationMode="ServerSide" />
</telerik:RadScheduler>

For the cases when requesting the web service from the server is not possible or undesired this can be changed to "Manual".

This way the templates will be rendered with the resource editing controls in place and the client-side code will take care of populating and reading them. As you've noted you can also use custom advanced templates. The advanced templates example actually includes all the required JavaScript to support client-side data binding.

Customizing the inline templates is currently possible only using client-side code (via the formCreated event).

Sincerely yours,
Tsvetomir Tsonev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Axe
Top achievements
Rank 1
answered on 28 Mar 2009, 01:31 AM
Thanks. I will check it out.
0
Roatin Marth
Top achievements
Rank 1
answered on 05 Jan 2010, 11:21 PM
tried to get the sample to work but I'm getting the following error after adding the service model reference, the latest telerik refs and converting to web project

Microsoft JScript runtime error: ASP.NET Ajax client-side framework failed to load.
0
Dimitar Milushev
Telerik team
answered on 07 Jan 2010, 04:38 PM
Hi,

You should check the General Troubleshooting section of our documentation. Also, check the Web Resource troubleshooting are to ensure that IIS is properly serving .axd resources.

Regards,
Dimitar Milushev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Scheduler
Asked by
Axe
Top achievements
Rank 1
Answers by
Axe
Top achievements
Rank 1
Atanas Korchev
Telerik team
T. Tsonev
Telerik team
Roatin Marth
Top achievements
Rank 1
Dimitar Milushev
Telerik team
Share this question
or