Showing appointments in a grid

12 posts, 2 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 19 Feb 2011 Link to this post

    I have an app wherein I store appointments in a DB.

    I - normally - show the appointments in RadScheduler. However, there are occasions when using the scheduler is not the most appropriate too, for example, when the use queries the data base for a period covering more than 1 month.

    In these cases, I use RadGrid to display the results of the query and this works just fine.

    [wait for it]

    But, I now have recurring appointments and these are stored using the recurrence rule in the master appointment. Is there a way for me to show the occurrences of these recurring appointments in a grid?

    I can think of doing it:
    1. Read the DB and set the DataSource of the Scheduler to the query result and then use the Scheduler's Appointments property as a DataSource for the grid.
    2. Read the DB and set the DataSource of the Scheduler to the query result and use the AppointmentDataBound event to create a new List<> to use as the DataSource of the grid.
    I haven't yet tried either of these, 'cos I'm sure I've seen an demo, or Code Library article on this very subject, but I'll be damned if I can find it.

    FWIW, I prefer the idea of the 2nd of the 2 options above as the AppointmentDataBound event gices me access to the DataItem used to create the appointment in the first place, can I have a lot of extra data in that object that I would, otherwise, have to query the DB again for.

    -- 
    Stuart
  2. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 21 Feb 2011 Link to this post

    It turns out doing the 2nd option wasn't all that hard.

    The difficult bit, with the scheduler and the grid loaded as controls on the same page, was getting the necessary events to fire in the right order.

    In short, here's what I did.

    My page includes a search control, with a button to fire off the search.
    1. I use the click event to fetch the data from the DB and assign it to the scheduler
    2. During the scheduler's OnAppointmentDataBound event, I add details of each appointment added to the scheduler (using the e.Appointment property for Start/End dates and not the underlying DataItem) to a List<>.
    3. During the Scheduler's OnDataBound event I call the Grid's Rebind method
    4. In the Grid's NeedDataSource event I simple assign the List<> (2) to the grid.

    Initially, I tried calling the grid's Rebind method from the button click that fired off the process and have that bind the Scheduler to the DB data and then get the List<> and assign it to the Grid. However, it turns out the all of the Grid stuff happened before any of the Scheduler stuff got started, so I always ended up with an empty Grid.

    I know there's not too much in the way of specifics here, but I'll try posting something more detailed later. However, feel free to ask questions if you need more detail in the meanwhile.

    -- 
    Stuart
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 21 Feb 2011 Link to this post

    There's always something, isn't there?

    Picture the scene...

    I have a recurring event on the 20th. The event occurs every 2 hours that day.

    If my Scheduler is in a view where the 20th is shown, AppointmentDataBound is called once for each appointment in the cycle.

    If, on the other hand, my Scheduler is in a view where the 20th is not shown, the AppointmentDataBound event is only called for the recurrence master appointment.

    Is there something I can do to for the recurring events to always be databound?

    -- 
    Frustrated of Grantham.
  5. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 21 Feb 2011 Link to this post

    Hello Stuart,

    You can parse the recurrence rule to get all occurrences of a recurring appointment -
    http://www.telerik.com/support/kb/aspnet-ajax/scheduler/how-to-display-all-radscheduler-appointments-in-gridview.aspx

    Would this be helpful in your case as well?


    Peter
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  6. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 21 Feb 2011 Link to this post

    Whilst I haven't checked, I suspect that the Scheduler isn't going to both firing the OnAppointmentDataBound event for any but the master appointment if none of the occurrences appear in its SelectedView.

    This is going to present a problem.

    :-(

    -- 
    Sad of Grantham
  7. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 21 Feb 2011 Link to this post

    Sorry Peter, I didn't see your reply.

    Yes, that is the article I was trying to find.

    -- 
    Happy of Grantham.
  8. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 21 Feb 2011 Link to this post

    Peter,

    Am I right in thinking I need to run the Start and End dates in the 2 lines that add the appointment to the table through the Scheduler's UTCToDisplay() method?

    -- 
    Stuart
  9. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 22 Feb 2011 Link to this post

    Hi Stuart,

    The appointments are stored by default in UTC format. Do you experience any problems in particular?

    Best wishes,
    Peter
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  10. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 22 Feb 2011 Link to this post

    Peter,

    The appointments are stored by default in UTC format. Do you experience any problems in particular?
    None, ATM, as GMT == UTC for a little while longer.

    But I guess this confirms that I do need to do the conversion before the data is added to the grid DataSource.

    Thx.

    -- 
    Stuart
  11. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 23 Feb 2011 Link to this post


    I imagine the Grid datasource is just for preview purposes and it does not affect the actual RadScheduler's datasource, so it would be save to do any conversion that  you need.

    I hope I am not misunderstanding your question.

    Regards,
    Peter
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  12. GISWebDev
    GISWebDev avatar
    11 posts
    Member since:
    Feb 2008

    Posted 23 Feb 2011 Link to this post

    Just a minor tweak may be needed... In the C# sample you reference (http://www.telerik.com/support/kb/aspnet-ajax/scheduler/how-to-display-all-radscheduler-appointments-in-gridview.aspx there is a typo:

    Line 413:            //a recurring appointement, these occurences will be generated now so they will be added once again    
    Line 414:            //to the DataTable. To prevent this, we use the following check:    
    Line 415:            if (a.RecurrenceState != RecurrenceState.Occurence)
    Line 416:            {
    Line 417:                appttable.Rows.Add(new string[] { a.Subject.ToString(), a.Start.ToString(), a.End.ToString() });

    Easiest to reference, look at line 415 above the word "Occurrence" is misspelled.

    Thanks for the example!
  13. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 24 Feb 2011 Link to this post


    Thanks for pointing this out, Ripsin. We have updated the kb article.

    Best wishes,
    Peter
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017