Binding to Database Example

Thread is closed for posting
37 posts, 0 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 29 Nov 2011 Link to this post

    Requirements

    RadControls version Q3 2012
    .NET version 4.0
    Visual Studio version 2010
    programming language C#
    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION
    A sample project which demonstrates how to bind the RadScheduleView to a database. For more details please refer to the following documentation:
    http://www.telerik.com/help/silverlight/radscheduleview-populating-with-data-binding-to-db-overview.html

    Steps to run the project:

    1. Create ScheduleViewDB and execute the sql query from the attachment.
    2. Change the connection string in Web.config file.
    3. Set the Web project as StartUp project.

    This should be enough to run and test the application.

    UPDATE: The latest version of ScheduleView Database examples is available in our XAML SDK Repository at the following link:
    https://github.com/telerik/xaml-sdk/tree/master/ScheduleView/Database
  2. C5C6CAD9-1D91-4711-8579-6605C7B449B1
    C5C6CAD9-1D91-4711-8579-6605C7B449B1 avatar
    7 posts
    Member since:
    Nov 2011

    Posted 09 Jan 2012 Link to this post

    this example doesn't work with the trial version of Q3 2011.

    Is it normal ?
  3. 19C325B1-797C-4BCB-A166-01FCA596C564
    19C325B1-797C-4BCB-A166-01FCA596C564 avatar
    1332 posts
    Member since:
    May 2015

    Posted 10 Jan 2012 Link to this post

    Hello,

     
    Could you please provide some more information about the problem? Do you have any problems with the database or with the control itself? 


    Greetings,
    George
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  4. C5C6CAD9-1D91-4711-8579-6605C7B449B1
    C5C6CAD9-1D91-4711-8579-6605C7B449B1 avatar
    7 posts
    Member since:
    Nov 2011

    Posted 10 Jan 2012 Link to this post

    It seems to be the database...

    I create the DB and run your sql script (no problems).

    I modify the web.config like this : 
    <add name="ScheduleViewEntities" 
    connectionString="metadata=res://*/AppData.ScheduleViewEntity.csdl|res://*/AppData.ScheduleViewEntity.ssdl|res://*/AppData.ScheduleViewEntity.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;Initial Catalog=ScheduleViewDB;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />  
    <add name="ScheduleViewDBEntities" 
    connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRES<b>S</b>;initial catalog=ScheduleViewDB;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

    When i build the project theirs errors...
    The first is in file ScheduleView_EF_SL.Web.appData.Category, Line 7 says: The class does'nt not implement the property CategoryName the the Interface ICategory

    their is also a borken reference to Telerik.Windows.Controls.ScheduleView into the Web project.
  5. 19C325B1-797C-4BCB-A166-01FCA596C564
    19C325B1-797C-4BCB-A166-01FCA596C564 avatar
    1332 posts
    Member since:
    May 2015

    Posted 13 Jan 2012 Link to this post

    Hello,

    Please, double check whether you have added a reference to the Telerik.Windows.Control.ScheduleView.dll file in the Web project. Also, make sure the DataBase is generated via the script.sql file, located in the archive.


    Greetings,
    George
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. C5C6CAD9-1D91-4711-8579-6605C7B449B1
    C5C6CAD9-1D91-4711-8579-6605C7B449B1 avatar
    7 posts
    Member since:
    Nov 2011

    Posted 13 Jan 2012 Link to this post

    Hi,

    I check the that the DB is create by the script. But i can't add the reference to Telerik.Windows.Control.ScheduleView.dll because i don't see it in the reference view.

    The only reference i can add from telerik is Telerik.Windows.RadUploadHandler. 
    http://nsa21.casimages.com/img/2012/01/13/120113021007922816.png 

    Did i have something to do to be able to add telerick dll references in the web project ? any configuration ?
  7. 19C325B1-797C-4BCB-A166-01FCA596C564
    19C325B1-797C-4BCB-A166-01FCA596C564 avatar
    1332 posts
    Member since:
    May 2015

    Posted 17 Jan 2012 Link to this post

    Hello,


    I would suggest adding the reference manually - you could browse to the directory where the telerik assemblies are installed and add Telerik.Windows.Control.ScheduleView.dll. By default, the latest dlls are located at "C:\Program Files (x86)\Telerik\RadControls for Silverlight Q3 2011 SP1\Binaries\Silverlight".


    All the best,
    George
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  8. ADDA128D-17E0-4982-973A-6C6346BE1491
    ADDA128D-17E0-4982-973A-6C6346BE1491 avatar
    32 posts
    Member since:
    Mar 2009

    Posted 13 Mar 2012 Link to this post

    Perhaps you would be so kind as to supply those of us who pay exactly the same fee to work with the VB version a sample of this project..?
  9. E01D1136-1945-42E1-8C4A-5E8C60D829F7
    E01D1136-1945-42E1-8C4A-5E8C60D829F7 avatar
    19 posts
    Member since:
    Mar 2011

    Posted 25 Jan 2013 Link to this post

    yes, I agree. A Vb sample project would help great deal. 
  10. 62081255-217C-4907-8F8C-F0E5E4678320
    62081255-217C-4907-8F8C-F0E5E4678320 avatar
    101 posts
    Member since:
    Jul 2012

    Posted 25 Jan 2013 Link to this post

    This is example is really great, it just has one drawback.

    The problem is that, when I want to show some recurring appointment for a given datetime range, I have to retrieve ALL appointment entities EVERY TIME from the database, because i can't tell, which of the appointments' occurences fall into the desired timeframe. 

    A SQL procedural explanation of parsing the 'RecurrencePattern' field would be more than appreciated, because then I could only get appointments i need to display them in current time range.
  11. 11003FA9-64D8-4477-91C3-84B3F7E03DDE
    11003FA9-64D8-4477-91C3-84B3F7E03DDE avatar
    5044 posts
    Member since:
    Sep 2017

    Posted 25 Jan 2013 Link to this post

    Hello,

    We've just updated this Code Library with a VB version of the project. Please download it and give it a try.

    As to the question about recurrent appointments - currently this is the only way to get them from the database. Thank you for sending your feedback, it will be considered.

    All the best,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  12. E01D1136-1945-42E1-8C4A-5E8C60D829F7
    E01D1136-1945-42E1-8C4A-5E8C60D829F7 avatar
    19 posts
    Member since:
    Mar 2011

    Posted 25 Jan 2013 Link to this post

    never expected such fast reply :) Thank You so much. This would really help a lot :)
  13. E2C08665-0252-4701-B7BF-43BF04455DB8
    E2C08665-0252-4701-B7BF-43BF04455DB8 avatar
    40 posts
    Member since:
    Dec 2009

    Posted 18 Feb 2013 Link to this post

    hi

    Firstly Im able to build this fine , I am running vs2012 sql 2012 and the C# version.

    However when I run this project I get an exception..

    The invocation of the constructor on type 'ScheduleView_DB_CS.ViewModel.ScheduleViewViewModel' that matches the specified binding constraints threw an exception. [Line: 11 Position: 37]

    the line in question is..

    System.Windows.Application.LoadComponent(this, new System.Uri("/ScheduleView_DB_CS;component/MainPage.xaml", System.UriKind.Relative));

    Any Ideas why this is happening?
    regards
    mike


    Sorry my error, web project was not set to start...!!

  14. D2409B4B-06AA-407D-8B38-C3FFF7145C5B
    D2409B4B-06AA-407D-8B38-C3FFF7145C5B avatar
    5 posts
    Member since:
    Jun 2012

    Posted 26 Mar 2013 Link to this post

    Hi, I downloaded the ScheduleView_DB_CS and it works fine for me, but I wonder if I can use the example without the button SAVE DATA. I would like when I double clic in any cell and I insert subject and description and press OK automatically insert the appointment in the data base without press button
  15. E01D1136-1945-42E1-8C4A-5E8C60D829F7
    E01D1136-1945-42E1-8C4A-5E8C60D829F7 avatar
    19 posts
    Member since:
    Mar 2011

    Posted 27 Mar 2013 Link to this post

    Hi Alberto,
        You can use the Appointment_Created event of the scheduleview control. You can write your code to save the appointment in DB here. 


  16. D2409B4B-06AA-407D-8B38-C3FFF7145C5B
    D2409B4B-06AA-407D-8B38-C3FFF7145C5B avatar
    5 posts
    Member since:
    Jun 2012

    Posted 27 Mar 2013 Link to this post

    Hi, Is there an example of Appointment_Created code that I can see, I am sorry but I am new in Silverlight I like it very much but it is new for me,

    Thanks in advance
  17. 11003FA9-64D8-4477-91C3-84B3F7E03DDE
    11003FA9-64D8-4477-91C3-84B3F7E03DDE avatar
    5044 posts
    Member since:
    Sep 2017

    Posted 29 Mar 2013 Link to this post

    Hello Alberto,

    You could find information about RadScheduleView events at the following link:
    http://www.telerik.com/help/silverlight/radscheduleview-events-overview.html

    You just need to move the following line:

    ScheduleViewRepository.SaveData();

    from the OnSaveExecuted method to the AppointmentCreated event handler.

    Greetings,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  18. E2C08665-0252-4701-B7BF-43BF04455DB8
    E2C08665-0252-4701-B7BF-43BF04455DB8 avatar
    40 posts
    Member since:
    Dec 2009

    Posted 30 Mar 2013 Link to this post

    Hi

    Can Custom Fields Be added to the SQLAppointment Table. And How would these be referenced back in on the client. If I add a custom field to the table and rebuild the domain service will that be sufficient?

    Mike
  19. 11003FA9-64D8-4477-91C3-84B3F7E03DDE
    11003FA9-64D8-4477-91C3-84B3F7E03DDE avatar
    5044 posts
    Member since:
    Sep 2017

    Posted 01 Apr 2013 Link to this post

    Hello Mike,

    Yes, that should be enough to add custom properties to the appointment.

    Regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  20. D2409B4B-06AA-407D-8B38-C3FFF7145C5B
    D2409B4B-06AA-407D-8B38-C3FFF7145C5B avatar
    5 posts
    Member since:
    Jun 2012

    Posted 01 Apr 2013 Link to this post

    Dear Yara

    I wonder if with this I still need to use the save button or not. When I edit or change an appointment , do I need use the same code for each event.

    Thanks
  21. E2C08665-0252-4701-B7BF-43BF04455DB8
    E2C08665-0252-4701-B7BF-43BF04455DB8 avatar
    40 posts
    Member since:
    Dec 2009

    Posted 01 Apr 2013 Link to this post

    Ok, One last issue. After adding it to the metadata how do I set the value. I don't need to have it appear in the edit appointment form. Just in the code behind,  the ability to set its value. Where can I do that?

    mike
  22. 11003FA9-64D8-4477-91C3-84B3F7E03DDE
    11003FA9-64D8-4477-91C3-84B3F7E03DDE avatar
    5044 posts
    Member since:
    Sep 2017

    Posted 02 Apr 2013 Link to this post

    Hello,

    You don't need Save button if you're using the events of the ScheduleView, but note that you should subscribe to AppointmentCreated, AppointmentEdited and AppointmentDeleted. The code in the events handlers is the same.

    As to the other question - you could use the events as well and set the custom properties in the event handlers.

    Kind regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  23. E2C08665-0252-4701-B7BF-43BF04455DB8
    E2C08665-0252-4701-B7BF-43BF04455DB8 avatar
    40 posts
    Member since:
    Dec 2009

    Posted 02 Apr 2013 Link to this post

    Hi Yana

    Did you mean to answer my question. Please explain in more detail how this is done. For example this is the insert method

    public void InsertSqlAppointment(SqlAppointment sqlAppointment)
            {
                if ((sqlAppointment.EntityState != EntityState.Detached))
                {
                    this.ObjectContext.ObjectStateManager.ChangeObjectState(sqlAppointment, EntityState.Added);
                }
                else
                {
                    this.ObjectContext.SqlAppointments.AddObject(sqlAppointment);
                }
            }

    how do I amend this to set my custom item?  In fact I will need to replace the subject textbox with a rad combo box. This rad combobox will look up a different table (List of users) and fill in the custom field with their ID. Can you provide documentation for this.

    regards
    mike


  24. E01D1136-1945-42E1-8C4A-5E8C60D829F7
    E01D1136-1945-42E1-8C4A-5E8C60D829F7 avatar
    19 posts
    Member since:
    Mar 2011

    Posted 02 Apr 2013 Link to this post

    Hello Mike,
       Just from my experience I can help you with following 
    1. If you have the sample handy, please debug it thoroughly to understand how its working. 
    2. If you are new to RIA services, suggest please check some blogs on how ria services work. 
    3. if you notice in the sample there is a Save Data method in ScheduleViewRepository so if you don't want to use the save button, just add 
    ScheduleViewRepository.SaveData() call to events like Appointment_Created, Appointment_Edited & Appointment_Deleted. the save method will save the details back in DB. You can then refresh the page to see your changes. 
    4. In order to add custom properties you can check following links 
    http://www.telerik.com/help/silverlight/radscheduleview-features-appointments-custom-appointment.html

    http://tv.telerik.com/watch/silverlight/using-custom-appointments-in-radscheduleview

    5. you can use a collection Property such as list in the View Model that you can bind to the RadCombo box that you want to use in the Edit appointment dialog, instead of the Subject textbox. 

    Hope this helps. 

    ~Supreet

  25. D2409B4B-06AA-407D-8B38-C3FFF7145C5B
    D2409B4B-06AA-407D-8B38-C3FFF7145C5B avatar
    5 posts
    Member since:
    Jun 2012

    Posted 04 Apr 2013 Link to this post

    Hi,

    I suscribe my code in the events handlers and I deleted the save button and it is working perfectly, thanks a lot to telerik team. The only problem I have is when I am in week mode and some appoitment is created and drag and drop works perfectly, but in month mode when I create them and want to drag and drop the appoitments does not appear any more if I put them in an day after or before the current week, even when exists in the Data Base.

    I also want  to change the languaje of options that appears when I want to add a new appoitmen or edit some option like recurrence, the date, etc. So I need to put everything in spanish. How can I do that
    Thanks again
  26. E2C08665-0252-4701-B7BF-43BF04455DB8
    E2C08665-0252-4701-B7BF-43BF04455DB8 avatar
    40 posts
    Member since:
    Dec 2009

    Posted 15 May 2013 Link to this post

    Hi

    Thanks For the Reply

    But Im still at a loss as to how to have the custom properties save to a specific column in the DB table (SqlAppointments) Are you saying the save changes is supposed to know which custom property goes to which custom column in the table? Can you please provide an example solution for 1 custom string property.

    regards
    mike

  27. 11003FA9-64D8-4477-91C3-84B3F7E03DDE
    11003FA9-64D8-4477-91C3-84B3F7E03DDE avatar
    5044 posts
    Member since:
    Sep 2017

    Posted 20 May 2013 Link to this post

    Hello Mike,

    Please check our reply at the other thread here.

    I would kindly ask you not to post the same question in different threads as this slows down our reply.
    Thank you for the understanding.

    Regards,
    Yana
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  28. 566AE076-626B-4B1B-B1D1-B9BB61C6377F
    566AE076-626B-4B1B-B1D1-B9BB61C6377F avatar
    155 posts
    Member since:
    Oct 2010

    Posted 17 Aug 2013 Link to this post

    I'll open with, I think the effort Telerik allocated to updating ScheduleView example projects was really well worth it and I'd like to thank them.

    I've spent some time trying to convert from the older version which used M2M to the new construct, and so far so good.  The example was quite helpful in setting up the SQL side of the solution.

    I was then trying to vet the "best practice" method Telerik would use to update the ScheduleView displayed data to the user.  Restated: we don't want to retrieve all records from the database if at all possible, we simply want to pull a given date range to the user and if the user then changes the ScheduleView range such as provided in the example using:

    VisibleRangeChanged = new DelegateCommand(VisibleRangeExecuted, param => true);

    a new call to the backend should trigger.  This update call seems to have been left out of the provided MVVM example.

    I would appreciate a bit of influence on how to best handle this, meaning is there a preferred method.

    Many thanks,
    Mark
  29. A406D4BD-5506-4062-8544-EFD0409F62C3
    A406D4BD-5506-4062-8544-EFD0409F62C3 avatar
    114 posts
    Member since:
    Apr 2014

    Posted 21 Aug 2013 Link to this post

    Hi Mark,

     Each time the VisibleRange property is changed, the VisibleRangeChangedCommand property of the RadScheduleView raises the VisibleRangeChanged command in the ScheduleViewViewModel. The VisibleRangeExecuted method is immediately executed with DateSpan object as parameter. This parameter should filter the appointments query to be only the visible data. 
    The VisibleRangeChanged command is included in both SL and WPF projects.

    Hope this shed some light to the subject.

    Regards,
    Ventzi
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  30. 566AE076-626B-4B1B-B1D1-B9BB61C6377F
    566AE076-626B-4B1B-B1D1-B9BB61C6377F avatar
    155 posts
    Member since:
    Oct 2010

    Posted 01 Sep 2013 Link to this post

    Hi Ventzi,

    Thank you for your additional clarification.  I've managed to narrow down where I find some difficulty. 
    Here is how you can reproduce what I am experiencing that made me believe something was amiss ...

    In your sample you have two functions one of which you've identified:

    private void VisibleRangeExecuted(object param)
            {
                if (!DesignerProperties.IsInDesignTool)
                {
                    if (!IsLoading && IsInitialDataLoad())
                    {
                        GenerateAppointments(param as DateSpan);
                    }
                }
            }
      
    private bool IsInitialDataLoad()
            {
                return Categories.Count == 0 && TimeMarkers.Count == 0;
            }

    In my testing, I have reordered the XAML so that the Monthly view is the default view, simple enough ....

    <telerik:RadScheduleView.ViewDefinitions>
         <telerik:MonthViewDefinition FirstDayOfWeek="Monday"/>
         <telerik:WeekViewDefinition FirstDayOfWeek="Monday"/>
         <telerik:DayViewDefinition />
         <telerik:TimelineViewDefinition VisibleDays="31" TimerulerGroupStringFormat="{}{0:dd ddd}"  TimerulerMajorTickStringFormat="{}{0:%M}.{0:%d}" LargeChangeInterval="15d" FirstDayOfWeek="Monday" MinorTickLength="1d" GroupTickLength="1d"/>
    </telerik:RadScheduleView.ViewDefinitions>

    Now when the scheduleview loads, the current month data is shown in the View, however if I go back a month stored data is not loaded.
    This is because the bool check in the sample returns false as it is no longer an initial load and "GenerateAppointments(param as DateSpan);" is never called. (This is what led me to believe there was something missing from the sample.)

    If I remove the check to IsInitialDataLoad, data no longer loads correctly across time frames. If I click on [Weekly] on the Scheduler, GenerateAppointments is called but no appointments appear in the weekly view.  Same for Daily, etc.  You should be able to reproduce the behavior by what I've provided.  If not please let me know and I'm happy to make the sample project slightly changed available.

    If I try and simplify your thread sample to a function like the one on your online example...
    private void VisibleRangeExecuted(object param)
         {
             this.GenerateAppointments(param as DateSpan);
         }

    it also does not load data across time frames

    Can you advise how this should be handled (and possibly update the sample)

    Thanks,
    Mark 
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.