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

Load theme before view presented, display only a number for date text, & slow loading times

6 Answers 46 Views
Calendar & Scheduling
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 29 Sep 2016, 01:58 PM

Hey Telerik team,

You were a big help before with the SideMenu SetHighlight so now I have 3 questions regarding the Calendar:

1. Currently in ViewWillAppear I style my calendar after creating it yet the theme/view mode/etc still changes after the view is presented to the screen. Is there a way to make this not happen and be styled before presenting to the screen? I've tried to style the calendar before adding the SubView but it still does the same thing.

2. I've tried to make the calendar day cells in a custom cell only display a number below the date (On both the iPad theme and standard theme). Unfortunately I can't find a way to do this - I have a custom cell but the events will display colored circles and things such as - 1 more... below. I'd like to make this just display "3" or "6". I've tried to set the maximum number of events to zero but that seems to ignore it completely. 

3. Last, the calendar seems to load slowly with the events. Is there a way to have the events set before going to the calendar so that the load time is near instant?

In case a photo helps, I'd like to make the calendar look like this but with a number instead of a circle below the date:

https://components.xamarin.com/view/fmcalendar?version=1.3

 

Thanks so much!



6 Answers, 1 is accepted

Sort by
0
Adrian
Telerik team
answered on 04 Oct 2016, 01:19 PM
Hi, Michael,

In order to give you any guidelines on the difficulties you are facing I would need a code snippet of the way you are customizing the calendar and the implementation of the custom day cell. You can also check the customization and populating with data articles in our documentation. There you will find explanation with code snippets on these topics.

Regards,
Adrian
Telerik by Progress
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
0
Michael
Top achievements
Rank 1
answered on 14 Oct 2016, 01:42 PM
Hi Adrian,

I've seen both those articles which is how I currently have my app set up. For the DataSource class there is EventsForDate which seems to be called when the Calendar is created (and not pushed to the screen). This creates slow loading for the user and results in the calendar pausing at the styling (where it changes the theme to iPad & pushes the events to the screen). I'd like to make this faster - where it only loads events on the month they are presented rather than every potential event. There is a potential for our app to have many many events. Would you know of a way to do this?

In terms of styling & presentation, when I create the calendar I set the theme to the iPad theme as it shows the "n more..." text. I'd like to remove the event circles and replace them just with the text of "n more.." on the non iPad theme - is there a way to do this? Setting the MaxEventsPerDate to zero seems to have it ignored.

Thank you,
Michael
0
Adrian
Telerik team
answered on 19 Oct 2016, 01:03 PM
Hello, Michael,

Loading events just for the presented month can be achieved by implementing TKCaledarDelegate's method WillNavigateToDate. You can check the month of the date that the calendar is going to navigate and if it is different than the current month invoke the Update method of the calendar's presenter. This would request again EventsForDate. This way you can load only the events of interest.

You can remove the circle by setting size of the EventShape property of TKCalendarDayCellStyle to CGSize.Empty and draw the events as text like in the code below:
public override void UpdateVisualsForCell(TKCalendar calendar, TKCalendarCell cell)
{
    if (cell is TKCalendarDayCell)
    {
        ((TKCalendarDayCell)cell).Style.EventShape.Size = CGSize.Empty;
        ((TKCalendarDayCell)cell).Style.DisplayEventsAsText = true;
    }
}

I can confirm that currently we have an issue with setting the MaxEventsCount property. I have logged it and updated your Telerik points for reporting this.


Regards,
Adrian
Telerik by Progress
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
0
Michael
Top achievements
Rank 1
answered on 26 Oct 2016, 07:39 PM
Adrian,

Thanks so much. I am nearing the UI I want with the Telerik Control.

In order to complete this - is there anyway to draw the selection circle before DidSelectDate? Reason being is that when the user taps a date I have the calendar close (this is intended) - but there's no selection circle until you have actually selected a date. Drawing a selection circle or tinting the specific cell would be ideal (such as WillSelectDate but this seems to not exist in the TKCalendarDelegate).

Thank you as always,
Michael
0
Michael
Top achievements
Rank 1
answered on 26 Oct 2016, 09:01 PM

Adrian,

I've also noticed that setting the DisplayEventAsText as true does not let me use EventAlignment (I'd like to center the text at the bottom, and horizontally). Is there a way to center the EventText? Once again I've tried a few options and reading the API doc but had not seen anything. Apologies for the formatting. The TextAlignment works fine if I were to change the date display for a cell.

Thank you,

Michael

1.public override void UpdateVisualsForCell(TKCalendar calendar, TKCalendarCell cell)
2.{
3.    if (cell is TKCalendarDayCell)
4.    {
5.        ((TKCalendarDayCell)cell).Style.EventAlignment = TKCalendarCellAlignment.Bottom |TKCalendarCellAlignment.HorizontalCenter;
6.    }
7.}
0
Adrian
Telerik team
answered on 31 Oct 2016, 11:54 AM
Hi, Michael,

1. An event that is called before DidSelectDate is ShouldSelectDate. You should return a boolean that indicates if the date should be selected:
public override bool ShouldSelectDate(TKCalendar calendar, NSDate date)
{
    Console.WriteLine("Called before didSelect");
    return true;
}

2. Yes, I can confirm that the text alignment doesn't apply when displaying events as text. Currently a possible option is to use the EventInsets property of the day cell's style.

Regards,
Adrian
Telerik by Progress
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
Tags
Calendar & Scheduling
Asked by
Michael
Top achievements
Rank 1
Answers by
Adrian
Telerik team
Michael
Top achievements
Rank 1
Share this question
or