如何呈现这一点

时间:2017-12-15 16:49:19

标签: sharepoint sharepoint-2010 sharepoint-2013

数据

Name    Date    Span
Bob     12/11   0700-1530
Sue     12/11   0700-1530
Bob     12/12   0700-1530
Sue     12/12   0700-1530
Bob     12/13   0700-1530
Sue     12/13   0700-1530
Bob     12/14   0700-1530
Sue     12/14   0700-1530
Bob     12/15   0700-1530
Sue     12/15   0700-1530
Sue     12/16   1200-1830

如何以每人一行的方式呈现如下数据?

      Sun      Mon         Tue         Wed         Thu         Fri        Sat
     10DEC    11DEC       12DEC       13DEC       14DEC       15DEC      16DEC
Bob         0700-1530   0700-1530   0700-1530   0700-1530   0700-1530
Sue         0700-1530   0700-1530   0700-1530   0700-1530   0700-1530  1200-1830

对于同一个人,不同日期的跨度可能会有所不同,并且任何给定周的名称可能会更多或更少。如果我没记错的话,这就是“交叉表查询”的目的,' Access可以做什么,但我不确定在SharePoint中。

1 个答案:

答案 0 :(得分:0)

没有办法实现开箱即用。您可能需要做的是使用客户端渲染来更改视图的显示方式。以下是更改视图渲染的js文件示例(不能实现您正在寻找的内容,但它是一个开始)。 customItem函数用于定义每个单元格的外观。然后,您可以在后期渲染中操作结果。希望这可以让你走上正确的道路。这是开始使用CSR的一个很好的指南:https://www.codeproject.com/Articles/620110/SharePoint-Client-Side-Rendering-List-Views

(function () {
    // Initialize the variable that stores the objects.
    var overrideCtx = {};
    overrideCtx.Templates = {};

    // Assign functions or plain html strings to the templateset objects:
    // header, footer and item.
    overrideCtx.Templates.Header = "<B><#=ctx.ListTitle#></B>" +
        "<hr><ul id='unorderedlist'>";

    // This template is assigned to the CustomItem function.
    overrideCtx.Templates.Item = customItem;
    overrideCtx.Templates.Footer = "</ul>";

    // Set the template to the:
    //  Custom list definition ID
    //  Base view ID
    overrideCtx.BaseViewID = 2;
    overrideCtx.ListTemplateType = 10057;

    // Assign a function to handle the
    // PreRender and PostRender events
    overrideCtx.OnPreRender = preRenderHandler;
    overrideCtx.OnPostRender = postRenderHandler;

    // Register the template overrides.
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();

// This function builds the output for the item template.
// It uses the context object to access announcement data.
function customItem(ctx) {

    // Build a listitem entry for every announcement in the list.
    var ret = "<li>" + ctx.CurrentItem.Title + "</li>";
    return ret;
}

// The preRenderHandler attends the OnPreRender event
function preRenderHandler(ctx) {

    // Override the default title with user input.
    ctx.ListTitle = prompt("Type a title", ctx.ListTitle);
}

// The postRenderHandler attends the OnPostRender event
function postRenderHandler(ctx) {

    // You can manipulate the DOM in the postRender event
    var ulObj;
    var i, j;

    ulObj = document.getElementById("unorderedlist");

    // Reverse order the list.
    for (i = 1; i < ulObj.children.length; i++) {
        var x = ulObj.children[i];
        for (j = 1; j < ulObj.children.length; j++) {
            var y = ulObj.children[j];
            if(x.innerText<y.innerText){                  
                ulObj.insertBefore(y, x);
            }
        }
    }
}