0

I currently have a weekday calendar with some events on it. My calendar is custom and does not contain any times. Only Sun-Sat columns and blocks of information for events.

The issue I'm having has to do with adjusting the scroll height(vertical scroll) for the column depending on the size/number of events that populate the calendar. So let's say I have several events populate, the scroll should automatically increase in response to the amount/size of events that populate the weekday calendar.

Currently, it does not do that, it cuts off some of the events.

I think it has to do with this code below:

/**
            * render the calendar body.
            * Calendar body is composed of several distinct parts.
            * Each part is displayed in a separated row to ease rendering.
            **/
          _renderCalendarBody: function($calendarContainer) {
            var self = this, options = this.options,
                showAsSeparatedUser = options.showAsSeparateUsers && options.users && options.users.length,
                $calendarBody, $calendarTableTbody;

            // create the structure
            $calendarBody = '<div class=\"wc-scrollable-grid\">';

            $calendarBody += '<table class=\"wc-time-slots\" style=\"margin:0px;padding:0px\">';
            $calendarBody += '<tbody>';
            $calendarBody += '</tbody>';
            $calendarBody += '</table>';
            $calendarBody += '</div>';
            $calendarBody = $($calendarBody);
            $calendarTableTbody = $calendarBody.find('tbody');

            self._renderCalendarBodyOddEven($calendarTableTbody);
            self._renderCalendarBodyFreeBusy($calendarTableTbody);
            self._renderCalendarBodyEvents($calendarTableTbody);

            $calendarBody.appendTo($calendarContainer);

            //set the column height
            $calendarContainer.find('.wc-full-height-column').height(options.timeslotHeight * options.timeslotsPerDay + 50); //<---Is this the issue? 

            //set the timeslot height
            $calendarContainer.find('.wc-time-slot').height(options.timeslotHeight - 1); //account for border

            //init the time row header height
            $calendarContainer.find('.wc-time-header-cell').css({
              height: (options.timeslotHeight * options.timeslotsPerHour) - 11,
              padding: 5
            });

            //add the user data to every impacted column
            if (showAsSeparatedUser) {
              for (var i = 0, uLength = options.users.length; i < uLength; i++) {
                $calendarContainer.find('.wc-user-' + self._getUserIdFromIndex(i))
                      .data('wcUser', options.users[i])
                      .data('wcUserIndex', i)
                      .data('wcUserId', self._getUserIdFromIndex(i));
              }
            }
          },

Also there is this:

/*
        * Resize the calendar scrollable height based on the provided function in options.
        */
      _resizeCalendar: function() {
        var options = this.options;
        if (options && $.isFunction(options.height)) {
          var calendarHeight = options.height(this.element);
          var headerHeight = this.element.find('.wc-header').outerHeight();
          var navHeight = this.element.find('.wc-toolbar').outerHeight();
          var scrollContainerHeight = Math.max(calendarHeight - navHeight - headerHeight, options.minBodyHeight);
          var timeslotHeight = this.element.find('.wc-time-slots').outerHeight();
          this.element.find('.wc-scrollable-grid').height(scrollContainerHeight);
          if (timeslotHeight <= scrollContainerHeight) {
            this.element.find('.wc-scrollbar-shim').width(0);
          }
          else {
            this.element.find('.wc-scrollbar-shim').width(this._findScrollBarWidth());
          }
          this._trigger('resize', this.element);
        }
      },

Specifically, the way I'm setting up column height but I tried to adjust the height but I'm having issues/does not solve the problem.

What could it be and what can I do to solve it? What else in the jquery weekcalendar should I look into?

Btw, here a link to the original jquery-week-calendar library I'm using: https://github.com/themouette/jquery-week-calendar/blob/master/jquery.weekcalendar.js

Kala J
  • 2,040
  • 4
  • 45
  • 85

1 Answers1

0

I think you're using jQuery to set the height using .height().

.height() does not accept any arguments (see: jQuery .height()).

Try using: .css({height: (options.timeslotHeight * options.timeslotsPerDay + 50)});

Grallen
  • 1,620
  • 1
  • 17
  • 16
  • hmm I'll try it but the original jquery weekcalendar uses it: https://github.com/themouette/jquery-week-calendar/blob/master/jquery.weekcalendar.js – Kala J May 19 '15 at 03:34
  • wait.. use `.css()`. It's more correct. I'll edit my answer. – Grallen May 19 '15 at 03:36
  • Yes but it also says, "The .height() method is recommended when an element's height needs to be used in a mathematical calculation." I don't think that's the issue. – Kala J May 19 '15 at 03:42
  • Yes, it is used to get the height, not set it. Please see documentation provided. – Grallen May 19 '15 at 04:08
  • In any event, it still doesn't work. It still cuts off my events in my week calendar when using .css() – Kala J May 19 '15 at 17:32