Giter VIP home page Giter VIP logo

apexcalendar's Introduction

Introduction

This is a set of classes and a component that make it easy to render a calendar view of a dataset in Visualforce on the Force.com platform.

Simple Example

If you just need a calendar, you can use the calendar component in any page to get a calendar view of any calendar.

<c:month altMonthNumber="9" altYearNumber="1977" />

Example 1

If you want to highlight a particular date, pass in the day number also.

<c:month altMonthNumber="9" altYearNumber="1977" altDayNumber="9" />

Example 2

Adding Data

If you want to add data to the calendar, use the Month class and the addMeasureValueToDate(Date d, Decimal mv) method and pass the instance of the Month class that you create to the component.

Here's an example controller that will add a measure to each date that shows how many days old I was on each day on or after my birthdate.

  public Month birthMonth {
    get {
      Date birthday = Date.newInstance(1977,12,9);
      birthmonth = new Month(birthday);
      for (Day d: birthmonth.days) {
        if (d.dateValue >= birthday) {
          birthMonth.addMeasureValueToDate(d.dateValue, birthday.daysBetween(d.dateValue));          
        }
      }
      return birthMonth;
    }
    set;
  }

Now I can pass the birthMonth property into my component and it will show my age in days for each date on the calendar view.

<c:month altMonth="{!birthMonth}" />

Example 3

Adding Weeks

Sometimes it helps to show a few weeks before the start of the month to put the current month in perspective. If you change the bufferWeeks property on your Month instance, it will add that number of weeks before the first partial week in your month view.

Let's pretend that I added the following line to the controller example above after creating the birthMonth:

birthmonth.bufferWeeks = 2;

Here's what the calendar would look like with the buffer weeks added:

Example 4

Just the Start

Many other things are possible that haven't been implemented yet. For example, you could highlight dates based on their rank, or you could add other types of "measure values" to each date (besides Integers) and have them display properly. You could also print multiple months in a few. But, this is a nice start and I figured that I'd share it so that others could contribute too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.