This is a migrated thread and some comments may be shown as answers.

Show single event indicator per day

3 Answers 71 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sal
Top achievements
Rank 1
Sal asked on 13 Feb 2015, 09:50 PM
So I wanted to know if there's a way to just show a single indicator under a day that has multiple events, similar to how the Calendar on the iPhone works. I thought if I added dayCell.style.maxEventsCount = 1; to my updatevisualsforcell method would do the trick but I guess that's not what it's for or I'm not doing it correctly. 

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 17 Feb 2015, 11:45 AM
Hello Sal,

Thank you for contacting us.

Your assumption is correct. The maxEventsCount should restrict the number of events that are displayed in a single calendar cell. However, there is an issue and this property is not respected when using TKCalendar with the iPhone theme. We know about the issue and the good news is that it will be addressed in our upcoming release later this month. Until then you can work around the issue by using a custom cell and overriding its drawEvents:rect: method. Consider the sample below:
@interface MyCell : TKCalendarDayCell
 
@end
 
@implementation MyCell
 
- (void)drawEvents:(CGContextRef)context rect:(CGRect)rect
{
    if (self.events.count > 0) {
        TKSolidFill *fill = [TKSolidFill solidFillWithColor:[UIColor redColor]];
        TKShape *eventShape = [TKPredefinedShape shapeWithType:TKShapeTypeCircle andSize:CGSizeMake(5, 5)];
        [eventShape drawInContext:context withCenter:CGPointMake(rect.size.width/2., rect.size.height-5) drawings:@[fill]];
    }
}
 
@end

You should also adopt TKCalendarDelegate and implement its calendar:viewForCellOfKind: method to replace the cell:
- (TKCalendarCell *)calendar:(TKCalendar *)calendar viewForCellOfKind:(TKCalendarCellType)cellType
{
    if (cellType == TKCalendarCellTypeDay) {
        return [MyCell new];
    }
    return nil;
}

I hope this helps. Should you have any other questions, we will be glad to assist.

Regards,
Jack
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sal
Top achievements
Rank 1
answered on 17 Feb 2015, 07:39 PM
Thanks Jack, I'll go ahead and use a custom cell for now since we are still using the trial product and in the demo stage of how it will work with the rest of our app. Will probably purchase the product by the end of the week and will look out for the update. 
0
Jack
Telerik team
answered on 18 Feb 2015, 08:05 AM
Hi Sal,

Thank you for this update. Do not hesitate to contact us if you have any questions.

Regards,
Jack
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Calendar
Asked by
Sal
Top achievements
Rank 1
Answers by
Jack
Telerik team
Sal
Top achievements
Rank 1
Share this question
or