Not displaying Event indicators in cell

6 posts, 1 answers
  1. Uddhao
    Uddhao avatar
    6 posts
    Member since:
    Nov 2014

    Posted 02 Jun 2015 Link to this post

    Hi,

      I,m trying telrik ui calendar for my app and it's looking good but i get trouble to show event(appointment) indicator on cell.

      Here is my code :

        <com.telerik.widget.calendar.RadCalendarView
                    android:id="@+id/calendarView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

     Here is my activity :

     public override View OnCreateView( Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
            {              
                var ignored = base.OnCreateView(inflater, container, savedInstanceState);

               var view = this.BindingInflate(Resource.Layout.myCalendar, null);

                calendarView = view.FindViewById<RadCalendarView>(Resource.Id.calendarView);

                calendarView.SelectionMode = CalendarSelectionMode.Single;

                 EventAdapter appointmnets = new EventAdapter(calendarView);

                List<Event> eventsSource = new List<Event>();

                // Get event from view model

                foreach (var app in this.ViewModel.Events)
                    {
                        dates.Add(app.StartDate.Ticks);
                        Event theEvent = new Event(app.Subject, app.StartDate.Ticks, app.EndDate.Ticks)
                        {
                            Title = app.Subject,
                            StartDate = app.StartDate.Ticks,
                            EndDate = app.EndDate.Ticks                 
                           
                        };
                        if (theEvent != null)
                        {
                            if (theEvent.StartDate <= theEvent.EndDate)
                            {
                                eventsSource.Add(theEvent);
                               
                            }

                        }
                    }
                }

                 appointmnets.Events = eventsSource;     
                calendarView.EventAdapter = appointmnets;

                   return view;
            }

        In EventAdapter of calendarView all appointment initialise but no any indicator display on calendar cell. Please help me to solve this.

        Thank you.

  2. Answer
    Antony Jekov
    Admin
    Antony Jekov avatar
    88 posts

    Posted 05 Jun 2015 Link to this post

    Hello Uddhao,

    Thank you for contacting the Android team.

    It is preferable you use the calendar that the Java.Util package provides. The RadCalendarView uses it to determine all internal date calculations. You also don't need to create a new Events Adapter.  You can just set the current one's events to your custom list of events. Something like this:
    RadCalendarView calendarView = FindViewById<RadCalendarView>(Resource.Id.calendarView);
    calendarView.SelectionMode = CalendarSelectionMode.Single;
     
    List<Event> eventsSource = new List<Event>();
    Calendar calendar = Calendar.Instance;
    eventsSource.Add (new Event("Title", calendar.TimeInMillis, calendar.TimeInMillis + 1));
     
    calendarView.EventAdapter.Events = eventsSource;

    If you choose not to use the Java.Util Calendar, then make sure the longs you pass to the events are in the same format. I would just use the Java.Util calendar, much easier solution.

    Let me know if there is still something unclear.

    Regards,
    Antony Jekov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
  4. Uddhao
    Uddhao avatar
    6 posts
    Member since:
    Nov 2014

    Posted 24 Jun 2015 in reply to Antony Jekov Link to this post

    @ Antony Jekov sorry for late response. I was busy with another task.

        Your solution working nice but there is one issue when event start date and end date different (eg. event start date - 12/5/2015 and end date is - 15/5/2015) then  event indication displayed only  for start date. So I added following code : 

                   calendar.Set(CalendarField.DayOfYear, StartDate.DayOfYear);               

                    long startEvent = calendar.TimeInMillis;

                    calendar.Set(CalendarField.DayOfYear,EndDate.DayOfYear);

                    long endEvent = calendar.TimeInMillis;

                    eventsSource.Add(new Event(Title, startEvent, endEvent + 1)); 

            Now event indication displaying at start date to end date but for some date it adding event indication even on this date no any event.

         So my question is what is the way to show event indication more than one day with same title ? 

         Thank you.

  5. Antony Jekov
    Admin
    Antony Jekov avatar
    88 posts

    Posted 25 Jun 2015 Link to this post

    Hello Uddhao,

    I am using the following code to show the same event more than once:
    RadCalendarView calendarView = new RadCalendarView(this);
     
    Calendar calendar = Calendar.Instance;
    long start = calendar.TimeInMillis;
    calendar.Add(CalendarField.Date, 3);
    long end = calendar.TimeInMillis;
    Event testEvent = new Event("Title", start, end);
     
    List<Event> events = new List<Event>();
    events.Add(testEvent);
     
    calendarView.EventAdapter.Events = events;

    It produces the screenshot I am sending you. Please let me know if you have any troubles with that.

    You might want to double check if this line produces the correct result in your case:
    calendar.Set(CalendarField.DayOfYear,EndDate.DayOfYear);


    Regards,
    Antony Jekov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Uddhao
    Uddhao avatar
    6 posts
    Member since:
    Nov 2014

    Posted 25 Jun 2015 in reply to Antony Jekov Link to this post

    Hi  Antony,

      I tried your solution but I getting error "endDate should be after startDate". I think it happen because i set calendar start date  using DayOfYear. 

     calendarView = view.FindViewById<RadCalendarView>(Resource.Id.calendarView);
     calendarView.SelectionMode = CalendarSelectionMode.Single; 

     List<Event> eventSource = new List<Event>();
     Calendar calendar = Calendar.Instance;

     calendar.Set(CalendarField.DayOfYear,StartDate.DayOfYear);               
     long startDate = calendar.TimeInMillis;             
     calendar.Set(CalendarField.Date, 2);
     long endDate = calendar.TimeInMillis;
     eventsSource.Add(new Event("Title", startDate, endDate));

     

     calendarView.EventAdapter.Events = eventSource;  

     Where is I'm doing wrong ?

    How I set start date and end date for calendar ?

    Thank you.

     
  7. Antony Jekov
    Admin
    Antony Jekov avatar
    88 posts

    Posted 30 Jun 2015 Link to this post

    Hello Uddhao,

    It is clear you are having issues with your data. First make sure that your dates are correct and then feed them to the RadCalendarView. Try using setTimeInMilliseconds instead. If you choose to use other methods like day of year setting, then make sure it succeeded before using it in the calendar.

    This is an issue outside of our control that needs to be resolved on your side.

    Let me know if you face a problem with the control once the data is correct.

    Regards,
    Antony Jekov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner