简体   繁体   English

jQuery工作日日历的滚动高度问题

[英]Issue with scrolling height for jquery weekday calendar

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. 仅Sun-Sat列和事件信息块。

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? 我应该在jquery weekcalendar中查看什么?

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 顺便说一句,这是我正在使用的原始jquery-week-calendar库的链接: https : //github.com/themouette/jquery-week-calendar/blob/master/jquery.weekcalendar.js

I think you're using jQuery to set the height using .height() . 我认为您正在使用jQuery通过.height()设置高度。

.height() does not accept any arguments (see: jQuery .height() ). .height()不接受任何参数(请参阅: jQuery .height() )。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM