1

我正在使用完整的日历。

这是问题的一个示例: 在此处输入图像描述

问题是非工作日无论如何都应该保持在首位。默认任务应该在 nwd 和超酷项目之间滑动。

有谁知道我可以在服务器端做什么,目前可以:

   var sortedList = eventList
            .OrderBy(p => p.resource).
            ThenBy(p => new
          DateTime(ConvertFromUnixTimestamp(p.start).Year,
          ConvertFromUnixTimestamp(p.start).Month,
          ConvertFromUnixTimestamp(p.start).Day)
          ).ThenBy(p => !p.isDate)
          .ThenBy(p => p.title).ToList();
        List<dynamic> finalList = new List<object>();

        for (int i = 0; i < sortedList.Count(); ++i)
        {
            var e = sortedList.ElementAt(i);
            finalList.Add(
                new
                {
                    id = i.ToString(),
                    realid = e.realid,
                    isDate = e.isDate,
                    title = e.title,
                    start = ResolveStartDate(StartDate(ConvertFromUnixTimestamp(e.start).AddSeconds(i))),
                    end = e.end,
                    description = e.description,
                    allDay = e.allDay,
                    resource = e.resource,
                    editable = e.editable,
                    color = e.color
                }
                );

        }


        JavaScriptSerializer js = new JavaScriptSerializer();
        string strJSON = js.Serialize(finalList);

或客户端,fullcalendar 似乎有:

function segCmp(a, b) {
    //return (b.msLength - a.msLength) * 100 + (a.event.start - b.event.start);
    return (a.event.start - b.event.start);
}


function segsCollide(seg1, seg2) {
    //return seg1.end > seg2.start && seg1.start < seg2.end;
    return false;
}



/* Event Sorting
-----------------------------------------------------------------------------*/


// event rendering utilities
function sliceSegs(events, visEventEnds, start, end) {
    var segs = [],
        i, len=events.length, event,
        eventStart, eventEnd,
        segStart, segEnd,
        isStart, isEnd;
    for (i=0; i<len; i++) {
        event = events[i];
        eventStart = event.start;
        eventEnd = visEventEnds[i];
        if (eventEnd > start && eventStart < end) {
            if (eventStart < start) {
                segStart = cloneDate(start);
                isStart = false;
            }else{
                segStart = eventStart;
                isStart = true;
            }
            if (eventEnd > end) {
                segEnd = cloneDate(end);
                isEnd = false;
            }else{
                segEnd = eventEnd;
                isEnd = true;
            }
            segs.push({
                event: event,
                start: segStart,
                end: segEnd,
                isStart: isStart,
                isEnd: isEnd,
                msLength: segEnd - segStart
            });
        }
    } 
    return segs.sort(segCmp);
}


// event rendering calculation utilities
function stackSegs(segs) {
    var levels = [],
        i, len = segs.length, seg,
        j, collide, k;
    for (i=0; i<len; i++) {
        seg = segs[i];
        j = 0; // the level index where seg should belong
        while (true) {
            collide = false;
            if (levels[j]) {
                for (k=0; k<levels[j].length; k++) {
                    if (segsCollide(levels[j][k], seg)) {
                        collide = true;
                        break;
                    }
                }
            }
            if (collide) {
                j++;
            }else{
                break;
            }
        }
        if (levels[j]) {
            levels[j].push(seg);
        }else{
            levels[j] = [seg];
        }
    }
    return levels;
}

这可以让跨越多天的事件始终保持在非工作日以下?在事件中将非工作日定义为 isDate。所以如果 event.isDate 那么它是一个非工作段。

谢谢

4

0 回答 0