Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Compact Calendar Day Style

    I am trying to build a calendar of 3 months using the SmartGWT Calendar component (Compact Calendar). So far I was succeeded in portraying all the requirements, except the color coding of each cell in the calendar. The requirement is to show the dates in Red/Green/Yellow based on the priority.

    I am trying the below code sample to show the red color on alternate days.

    @Override
    protected String getDayBodyHTML(Date date, CalendarEvent[] events, Calendar calendar, int rowNum, int colNum) {
    String returnStr = date.getDate() + "";
    if(date.getDate()%2 == 0) {
    calendar.setDayBodyBaseStyle("calMonthDayBodyH");
    } else {
    calendar.setDayBodyBaseStyle("calMonthDayBody");
    }
    return returnStr;
    }

    Using the above code snippet I got the calendar like the chess board, which is perfect.

    When I check the Style of the cell where the date is an odd number in Firebug it is showing as "calMonthDayBodyH" as expected, but the problem is when I mouse over on that date, the style is changing to "calMonthDayBodyOver" instead of "calMonthDayBodyHOver" and when the mouse out is performed it is setting the class name back to “calMonthDayBody”, hence the style is lost.

    Can you please let me know what is the solution to overcome this problem?

    #2
    From Sanjiv's note:

    The code you have is changing the base style in an API that is supposed to return the html contents so it’s not surprising that the over CSS class is not being applied as expected.

    The ListGrid supports the notion of allowing the baseStyle to be overridden dynamically via the getBaseStyle(.…) override point as seen in this sample :

    http://www.smartclient.com/smartgwt/showcase/#grid_appearance_hilite_replace

    Looking at the API the Calendar class does not have a similar API. Instead you can do some thing like returning <span style=”background-color:red”> returnStr </span> but that will obviously not color the entire cell red, just the area of the date text..

    Comment

    Working...
    X