SharePoint 2013时间轴着色无效 [英] SharePoint 2013 Timeline coloring is not working

查看:88
本文介绍了SharePoint 2013时间轴着色无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我想用特定列的数据为时间轴着色。此列名为Topic。所以我写了一些代码并将其添加到我的SharePoint网站,但它没有用。这是我使用的代码:



Hi!
I want to color a timeline with data of a specific column. This column is named Topic. So I wrote some code and added it to my SharePoint site but it didn't work. Here's the code I used:

var timeline = (function() {
    var colorCodes = {
        "Flyer / brochure": "#ff757a", //red
        "Decor / texture": "rgb(130, 202, 255)", //blue
        "Product": "rgb(150, 222, 186)", //green
        "Benchmark": "rgb(200, 216, 216)", //gray
        "Target groups / markets": "rgb(216, 216, 216)", //gray
        "Pricing": "rgb(216, 200, 216)", //gray
        "Logistic": "rgb(216, 216, 200)" //gray
    };
    var timer;

    return {
    "processTimeline" : function(customColorCodes){

    if(customColorCodes != null){
        colorCodes = customColorCodes;
        }

        if ($("div.ms-webpart-zone table.ms-listviewtable > tbody > tr").length)
            colorTimeline();
        else
            timer = setTimeout(colorTimeline, 1000);
        }
    }

    function colorTimeline() {
        if (timer != null) {
            clearTimeout(timer);
        }

        //$("div.ms-webpart-zone").each(function () {
        //$(".ms-webpart-chrome").each(function () {

        $.expr[':'].hasClassStartingWith = function(obj){
            return (/\bms-webpart-chrome/).test(obj.className);
        };

        $('div:hasClassStartingWith').each(function () {

            var webpart = $(this);
            var cnt = 0;
            var found = false;
            webpart.find("table.ms-listviewtable > thead > tr.ms-viewheadertr > th").each(function () {
                cnt++;
                if ($(this).children("div.ms-vh-div").attr('name') == 'Topic') {
                    found = true;
                    return false;
                }
            });

            if (!found)
                return;

            webpart.find("table.ms-listviewtable > tbody > tr > td:nth-child(" + cnt + ")").each(function () {
                var topic = ($(this).text());
                var title = ($(this).siblings("td.ms-vb-title").eq(0).text());
                var barTitle = webpart.find("span.ms-tl-barTitle").filter(function () { return $(this).text() == title });

                colorBar(barTitle.parent(), topic);
            });
        });
    }

    function colorBar(bar, topic) {
        bar.css("background-color", colorCodes[topic]);
    }
}());





因此,当我将此代码填充到我的SharePoint网站时,没有任何反应。

我们已经使用此脚本为任务状态的时间线着色。因此,必须在Sharepoint视图中显示Task Name和Task Status列。

有没有人知道错误发生的地方或代码的哪一部分需要更改?

谢谢



So when i populate this code to my SharePoint site nothing happens.
We already use this script for coloring the timeline for the task status. Herefore the Task Name and the Task Status column have to be shown in the Sharepoint view.
Has anybody an idea where the error occurs or which part of the code has to be changed?
Thanks

推荐答案

div.ms-webpart-zone table.ms-listviewtable> tbody> tr)。length)
colorTimeline();
else
timer = setTimeout(colorTimeline, 1000 );
}
}

function colorTimeline(){
if (timer!= null ){
clearTimeout(timer);
}

//
("div.ms-webpart-zone table.ms-listviewtable > tbody > tr").length) colorTimeline(); else timer = setTimeout(colorTimeline, 1000); } } function colorTimeline() { if (timer != null) { clearTimeout(timer); } //


(div.ms-webpart-zone)。each(function(){
//
("div.ms-webpart-zone").each(function () { //


(。ms-webpart-chrome)。each(function(){
(".ms-webpart-chrome").each(function () {


这篇关于SharePoint 2013时间轴着色无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆