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

7 posts, 0 answers
  1. Michael
    Michael avatar
    7 posts
    Member since:
    Jun 2016

    Posted 29 Sep Link to this post

    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!



  2. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 04 Oct Link to this post

    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
  3. DevCraft banner
  4. Michael
    Michael avatar
    7 posts
    Member since:
    Jun 2016

    Posted 14 Oct Link to this post

    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
  5. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 19 Oct Link to this post

    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
  6. Michael
    Michael avatar
    7 posts
    Member since:
    Jun 2016

    Posted 26 Oct in reply to Adrian Link to this post

    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
  7. Michael
    Michael avatar
    7 posts
    Member since:
    Jun 2016

    Posted 26 Oct in reply to Adrian Link to this post

    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.}
  8. Adrian
    Admin
    Adrian avatar
    167 posts

    Posted 31 Oct Link to this post

    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
Back to Top
DevCraft banner