SharePoint 列表:使用 JavaScript 客户端对象模型的列值总和 [英] SharePoint List : Sum of Column Values using JavaScript Client Object Model

查看:40
本文介绍了SharePoint 列表:使用 JavaScript 客户端对象模型的列值总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 SharePoint 列表称为跟踪器".它有两列,第一列是 Month 列(计算 col)和 Duration(计算 col).月份的值从一月到十二月.持续时间列包含数值.我正在尝试获取每个月的持续时间列中的值总和.我尝试通过获取一个数组中的列表项和另一个数组中的月份值来尝试.我试图在两个数组中循环,以下面的格式将值存储在第三个数组中

I have SharePoint list called as "Tracker". It has two column one is Month column (which is calculated col) and Duration(which is calculated col). Month has values from Jan to Dec. Duration col contains numeric values. I am trying to get sum of values in duration column for each Month. I tried by getting list items in one array and month values in another array. I am trying to loop in both arrays store values in third array in below format

[{一月,一月的持续时间总和},{二月,二月的持续时间总和}....]

[{Jan, Sum of Duration in Jan}, {Feb, Sum of Duration in Feb}....]

请帮忙.

提前致谢

推荐答案

好的,我通过使用多维数组解决了上述问题.For 循环月份列,然后在相同的 for 循环中为 SharePoint 列表项创建了第二个循环.

Ok i solved the above question by using multidimensional array. For looped month column and then in same for loop created second loop for SharePoint list items.

    for (var i = 0; i < monthChoices.length; i++){
        chartSeries[i] = [];
        var monthTotal = 0;
        for(var j= 0; j< arrItems.length; j++ ){
            if(monthChoices[i]==arrItems[j].get_item("Month")  && arrItems[j].get_item("Duration")!= ""){
                monthTotal += arrItems[j].get_item("Duration");
            }
        }
        chartSeries[i].push([monthChoices[i], monthTotal]);
        console.log(chartSeries[i]);
    }

这篇关于SharePoint 列表:使用 JavaScript 客户端对象模型的列值总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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