Client Binding & DbSchedulerProviderBase

8 posts, 0 answers
  1. Axe
    Axe avatar
    88 posts
    Member since:
    Feb 2007

    Posted 18 Mar 2009 Link to this post

    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 to use the MyDbSchedulerProvider instead by passing in the name of provider from web.config:
    1     private WebServiceAppointmentController Controller  
    2     {  
    3         get 
    4         {  
    5             if (_controller == null)  
    6             {  
    7                 //_controller =  
    8                 //    new WebServiceAppointmentController(  
    9                 //        new XmlSchedulerProvider(HttpContext.Current.Server.MapPath("~/App_Data/Appointments_Outlook.xml"),   
    10                 //            false));  
    12                 _controller = new WebServiceAppointmentController("ReadOnlySchedulerData");  
    13             }  
    14             return _controller;  
    15         }  
    16     }  

    I then ran the page and got the same error on the method below on line 16:
    1         private void LoadResources(Appointment apt)  
    2         {  
    4             using (DbConnection conn = OpenConnection())  
    5             {  
    6                 DbCommand cmd = DbFactory.CreateCommand();  
    7                 cmd.Connection = conn;  
    9                 cmd.Parameters.Add(CreateParameter("@ClassID", apt.ID));  
    10                 cmd.CommandText = "SELECT [TeacherID] FROM [DbProvider_Classes] WHERE [ClassID] = @ClassID AND [TeacherID] IS NOT NULL";  
    11                 using (DbDataReader reader = cmd.ExecuteReader())  
    12                 {  
    13                     if (reader.Read())  
    14                     {  
    15                         Resource teacher = apt.Owner.Resources.GetResource("Teacher", reader["TeacherID"]);  
    16                         apt.Resources.Add(teacher);  
    17                     }  
    18                 }  
    20                 cmd.Parameters.Clear();  
    21                 cmd.Parameters.Add(CreateParameter("@ClassID", apt.ID));  
    22                 cmd.CommandText = "SELECT [StudentID] FROM [DbProvider_ClassStudents] WHERE [ClassID] = @ClassID";  
    23                 using (DbDataReader reader = cmd.ExecuteReader())  
    24                 {  
    25                     while (reader.Read())  
    26                     {  
    27                         Resource student = apt.Owner.Resources.GetResource("Student", reader["StudentID"]);  
    28                         apt.Resources.Add(student);  
    29                     }  
    30                 }  
    31             }  
    32         }  

    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.

  2. Axe
    Axe avatar
    88 posts
    Member since:
    Feb 2007

    Posted 19 Mar 2009 Link to this post

    I just checked out the WCF demo 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?
  3. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 20 Mar 2009 Link to this post

    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?

    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.
  4. Axe
    Axe avatar
    88 posts
    Member since:
    Feb 2007

    Posted 21 Mar 2009 Link to this post

    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 -

    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 - 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.


  5. T. Tsonev
    T. Tsonev avatar
    2794 posts

    Posted 24 Mar 2009 Link to this post

    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" />

    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.
  6. Axe
    Axe avatar
    88 posts
    Member since:
    Feb 2007

    Posted 27 Mar 2009 Link to this post

    Thanks. I will check it out.
  7. Roatin Marth
    Roatin Marth avatar
    65 posts
    Member since:
    Nov 2007

    Posted 05 Jan 2010 Link to this post

    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.
  8. Dimitar Milushev
    Dimitar Milushev avatar
    555 posts

    Posted 07 Jan 2010 Link to this post


    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.

    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.
Back to Top