Javascript Fullcalendar.io在一行中显示三个事件

Javascript Fullcalendar.io在一行中显示三个事件,javascript,jquery,fullcalendar,Javascript,Jquery,Fullcalendar,我使用的是fullcalendar.io,常规视图仅显示我想要实现的目标。这可以通过将三个链接放在一个元素中来实现。此td元素是通过fullcalendar.io库生成的 以下是我迄今为止所取得的成就: for (i = 0; i < levelCnt; i++) { // iterate through all levels levelSegs = segLevels[i]; col = 0; tr = $('<tr/>'); segMatrix.push(

我使用的是fullcalendar.io,常规视图仅显示我想要实现的目标。这可以通过将三个链接放在一个
元素中来实现。此td元素是通过fullcalendar.io库生成的

以下是我迄今为止所取得的成就:

for (i = 0; i < levelCnt; i++) { // iterate through all levels
  levelSegs = segLevels[i];
  col = 0;
  tr = $('<tr/>');

  segMatrix.push([]);
  cellMatrix.push([]);
  loneCellMatrix.push([]);

  // levelCnt might be 1 even though there are no actual levels. protect against this.
  // this single empty row is useful for styling.
  if (levelSegs) {

    var levelSegsDivided = Math.ceil(levelSegs.length / 3);

    iterationStart = 0;
    iterationEnd = 3;

    for (k = 0; k < levelSegsDivided; k++) {

      var elems;

      for (j = iterationStart; j < iterationEnd; j++) {
        seg = levelSegs[j];

        if (seg != null) {

          emptyCellsUntil(seg.leftCol);

          // create a container that occupies or more columns. append the event element.
          td = $('<td class="fc-event-container"/>').append(seg.el);
          console.log(seg.el);
          //if (seg.leftCol != seg.rightCol) {
          //    td.attr('colspan', seg.rightCol - seg.leftCol + 1);
          //}
          //else { // a single-column segment
          //    loneCellMatrix[i][col] = td;
          //}

          while (col <= seg.rightCol) {
            cellMatrix[i][col] = td;
            segMatrix[i][col] = seg;
            col++;
          }

          tr.append(td);

          iterationStart = iterationEnd;
          iterationEnd = iterationEnd + 3;
        }
      }
    }

    //for (j = 0; j < levelSegs.length; j++) { // iterate through segments in level
    //  seg = levelSegs[j];

    //  emptyCellsUntil(seg.leftCol);

    //  // create a container that occupies or more columns. append the event element.
    //  td = $('<td class="fc-event-container"/>').append(seg.el);
    //  if (seg.leftCol != seg.rightCol) {
    //    td.attr('colspan', seg.rightCol - seg.leftCol + 1);
    //  }
    //  else { // a single-column segment
    //    loneCellMatrix[i][col] = td;
    //  }

    //  while (col <= seg.rightCol) {
    //    cellMatrix[i][col] = td;
    //    segMatrix[i][col] = seg;
    //    col++;
    //  }

    //  tr.append(td);
    //}
}

emptyCellsUntil(colCnt); // finish off the row
this.bookendCells(tr);
tbody.append(tr);
for(i=0;i虽然(col)您的活动是在同一时间进行的吗?@ChintanMirani否,它们在不同的时间进行。例如2016年2月16日10:00和2016年2月16日11:00等。您是否设法做到了这一点?
renderSegRow: function(row, rowSegs) {
  var colCnt = this.colCnt;
  var segLevels = this.buildSegLevels(rowSegs); // group into sub-arrays of levels
  var levelCnt = Math.max(1, segLevels.length); // ensure at least one level
  var tbody = $('<tbody/>');
  var segMatrix = []; // lookup for which segments are rendered into which level+col cells
  var cellMatrix = []; // lookup for all <td> elements of the level+col matrix
  var loneCellMatrix = []; // lookup for <td> elements that only take up a single column
  var i, levelSegs;
  var col;
  var tr;
  var j, seg;
  var td;

  // populates empty cells from the current column (`col`) to `endCol`
  function emptyCellsUntil(endCol) {
    while (col < endCol) {
      // try to grab a cell from the level above and extend its rowspan. otherwise, create a fresh cell
      td = (loneCellMatrix[i - 1] || [])[col];
      if (td) {
        td.attr(
          'rowspan',
          parseInt(td.attr('rowspan') || 1, 10) + 1
        );
      }
      else {
        td = $('<td/>');
        tr.append(td);
      }
      cellMatrix[i][col] = td;
      loneCellMatrix[i][col] = td;
      col++;
    }
  }

  for (i = 0; i < levelCnt; i++) { // iterate through all levels
    levelSegs = segLevels[i];
    col = 0;
    tr = $('<tr/>');

    segMatrix.push([]);
    cellMatrix.push([]);
    loneCellMatrix.push([]);

    // levelCnt might be 1 even though there are no actual levels. protect against this.
    // this single empty row is useful for styling.
    if (levelSegs) {
      for (j = 0; j < levelSegs.length; j++) { // iterate through segments in level
        seg = levelSegs[j];

        emptyCellsUntil(seg.leftCol);

        // create a container that occupies or more columns. append the event element.
        td = $('<td class="fc-event-container"/>').append(seg.el);
        if (seg.leftCol != seg.rightCol) {
          td.attr('colspan', seg.rightCol - seg.leftCol + 1);
        }
        else { // a single-column segment
          loneCellMatrix[i][col] = td;
        }

        while (col <= seg.rightCol) {
          cellMatrix[i][col] = td;
          segMatrix[i][col] = seg;
          col++;
        }

        tr.append(td);
      }
    }

    emptyCellsUntil(colCnt); // finish off the row
    this.bookendCells(tr);
    tbody.append(tr);
  }

  return { // a "rowStruct"
    row: row, // the row number
    tbodyEl: tbody,
    cellMatrix: cellMatrix,
    segMatrix: segMatrix,
    segLevels: segLevels,
    segs: rowSegs
  };
}