如何呈现这一点

问题描述 投票:-1回答:1

数据

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中。

sharepoint sharepoint-2010 sharepoint-2013
1个回答
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);
            }
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.