We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

dynamic data for sfCalendar

Hi, I'm working off the sample AppointmentsDemo and trying to populate AppointmentSource from data in sqlite. I pass in month, year and a class object and i get the data ok and see it is added to appointment class, however the converter doesn't pick it up, the parameter count is always 0, method is below, any help appreciated.

public List<Post> GetAccountCalendarData(int month, int year, Account myObject)
        {
            string firstDay = GetFirstDayOfMonth(month).ToString();
            string lasttDay = GetLastDayOfMonth(month).ToString();
            DateTime fDay = Convert.ToDateTime(firstDay);
            DateTime lDay = Convert.ToDateTime(lasttDay);
            int m = month;
            int y = year;
         
            var items = (from s in Table<Post>()
                         where s.PostType.Equals("calendar")
                         && s.StartDate >= fDay && s.StartDate <= lDay
                           && s.AccountId == myObject.Id
                         select s).OrderBy(s => s.Id).ToList();
           
            AppointmentSource appointment = new AppointmentSource();
            
            foreach (var data in items)
            {
                // this is where i add it to dictionary in AppointmentSource
                appointment.Add(Convert.ToDateTime(data.StartDate), new Appointment(data.Title.ToString(), data.BodyHtml.ToString()));
            }
            return items;
        }

3 Replies

VR Vijayalakshmi Roopkumar Syncfusion Team August 5, 2016 03:07 PM UTC

Hi Rod, 
Thank you for contacting Syncfusion Support. 
We have prepared a sample base on your update. In this sample we have used converter to get the appointment and bound that converter into the CellTemplate. 
Please download the sample form the below link
Sample:CalAppoimentSample 
Could you please let us know whether this is the requirement you are stating in your update? If not, can you please modify our sample into issue reproducing or brief about your requirement clearly. So that it would be helpful for us to proceed further on this. 
Regards,
Vijayalakshmi.V.R  



RB Rod Barrand August 5, 2016 08:48 PM UTC

Thank you, this seems like it will work for me, the only issue i have now is my collection also contains a specific time, like 03/08/2016 2:15:00 AM
I need to keep the time in order to display it
When i run through the converter the appointments.ContainsKey is never true unless its 12:00:00
I'll try and workout how i can just compare the date part and should be good to go

Thanks again
Rod



VR Venkateshwaran Ramdoss Syncfusion Team August 8, 2016 06:10 PM UTC

Hi Rod, 

Thank you for your update. 

We have sort the appointments using the Dictionary key. We have prepared a sample using the same and it can be downloaded from the below link. 


Code snippet: 
if (appointments != null) 
            { 
                var appoinments = appointments.Keys.Where(datatime => datatime.Date == date).ToList(); 
                if(appoinments.Count > 0) 
                { 
                    appoinments.Sort(); 
                    ObservableCollection<string> AppoinmentInfo = new ObservableCollection<string>(); 
                    foreach (var datetime in appoinments) 
                    { 
 
                       foreach(var details in appointments[datetime].Descriptionlist) 
                        { 
                            AppoinmentInfo.Add(details); 
                        } 
                        AppoinmentInfo.Add("Time:" + datetime.Hour+":"+ datetime.Minute+":"+ datetime.Second); 
                    } 
                    return AppoinmentInfo; 
                } 
            } 


Regards, 
Venkateshwaran V.R. 


Loader.
Live Chat Icon For mobile
Up arrow icon