Skip to Content

Recently I had a requirement to modify a calendar control which looks like below.

test.PNG

Requirement:

Requirement was to create a home page for employee attendance regularization application which shows a calendar.

calendar control should display employee’s attendance data( In/out time) for selected month.

Achievable tasks:

1. background color using


calendar.toggleDatesType([ "2013/04/12" ], sap.me.CalendarEventType.Type07, true);


2. meaning of colors using CALENDAR LEGEND.

sddsd.JPG

Challenge :

1. Custom labels below the dates

Calendar control ( sap.m.Calendar ) does not have such property (as per my knowledge) to set the labels on / after dates.

Using extend() method we can extend existing control and give some new properties and aggregation and all.

As per the link extend TreeNode in SAPUI5 the function renderInnerAttribures is a specific hook of the TextFieldRenderer. As it is not supported for Tree, I found that it is also not supported for calendar.

So as shown in above link i also used the  onAfterrRendering() method of sap.ui.core.Control and customized my Calendar as below.

I searched for the CssClass of that control area which actually contains the Dates as shown below.

(press F12 on browser window or right click and click on “Inspect Element” )

/wp-content/uploads/2014/03/sdada_421350.png

code:


calendar = new sap.me.Calendar({
  dayHeight:80,
  monthsPerRow : 1,
  currentDate : "2013/04/30",
  });
calendar.onAfterRendering = function(oEvent) {
  var divs = $('.sapMeCalendarMonthDays').children();
  var i;
  var length = divs.length;
  var classes;
  for(i=0;i<length;i++)
  {
  classes = $(divs[i]).attr('class');
  $(divs[i]).append('<br/><span style="width:100%;display:block;font-size:0.5em;font-weight:bold; color:green">In:10:30</span><span style="width:100%;display:block;font-size:0.5em;font-weight:bold; color:green">Out:06:30</span>');
//check the condition
if(i==3)
  $(divs[i]).addClass('sapMeCalendarType04');
if(i==11)
  $(divs[i]).addClass('sapMeCalendarType07');
  }
  };

out put.


asdadadas.JPG

This document was generated from the following discussion: Calendar control modification

Please provide your inputs if i am wrong somewhere or missing something

Happy Learning

Below are few links for reference.

Documentation/AdvancedTopics/OnTheFlyControlDefinition – SAPUI5 Wiki (TIP CORE User Interface)

Documentation/AdvancedTopics/OnTheFlyControlExample – SAPUI5 Wiki (TIP CORE User Interface)

Documentation/AdvancedTopics/CompositeControl – SAPUI5 Wiki (TIP CORE User Interface)

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Haripriya k

    Hi Sir,

    i used sap.me.calender in that me apply a color to a particular date ,but how to decrease that color like legend.Please reply for this sir.

    (0) 

Leave a Reply