[英]How do I count a specfic text value in Sharepoint List column
Im currently trying to count the amount times a specific text string ( "1 JAN" & "2 FEB") occurs in SharPoint List column. 我目前正在尝试计算在SharPoint List列中出现特定文本字符串(“ 1 JAN”和“ 2 FEB”)的次数。 Below is my code it only returns the first text srting value it does not count 下面是我的代码,它仅返回不计算的第一个文本srting值
function ResultsAT(xData, status) {
var Month = []
var dCounts = [i]
var i = 0;
var dNumber = 0;
var TableRowScBrd = "<table>";
TableRowScBrd += "<TR><TH style='text-align: Left'>CLIENT</TH><TH>JAN</TH><TH>FEB</TH><TH>MAR</TH><TH>APR</TH><TH>MAY</TH><TH>JUN</TH><TH>JUL</TH><TH>AUG</TH><TH>SEP</TH><TH>OCT</TH><TH>NOV</TH><TH>DEC</TH><TH>Total</TH></TR>";
$(xData.responseXML).find("z\\:row").each(function () {
i = i + 1
var sReportMonth = $(this).attr("ows_ReportMonth");
var sServiceManager = $(this).attr("ows_ServiceManager");
sServiceManager = sServiceManager.substr(sServiceManager.indexOf("#") + 1);
var dCounts = $(this).attr("ows_ReportMonth");
var Manager = sReportMonth + sServiceManager;
var dReasons = $(this).attr("ows_ReportMonth");
dReasons = dReasons.substr(dReasons.indexOf("#") + 1);
if (Month[sServiceManager] == undefined)
{
Month[sServiceManager] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
}
if (Month[sServiceManager] != undefined)
{
}
if (dReasons == "1 JAN") { Month[sServiceManager][0] = dCounts; }
if (dReasons == "2 FEB") { Month[sServiceManager][1] = dCounts; }
if (dReasons == "3 MAR") { Month[sServiceManager][2] = dCounts; }
dNumber = Month[sServiceManager][0] + Month[sServiceManager][1] + Month[sServiceManager][2]
// TableRowScBrd += "<TR><td>" + sReportMonth + "</td><td>" + sServiceManager + "</td><td>" + i + "</td><TR>";
});
var key = "";
for (key in Month) {
TableRowScBrd += "<TR><td style='text-align: Left'>" + key + "</td><td>" + Month[key][0] + "</td><td>" + Month[key][1] + "</td><td>" + Month[key][2] + "</td><TR>";
}
TableRowScBrd += "</Table>";
$("#tasksAT").append(TableRowScBrd);
}
Whilst I cant run your code now to verify, im pretty sure that it returns an xml structure of rows\\row. 虽然我现在无法运行您的代码进行验证,但我非常确定它返回的是行\\行的xml结构。 Therefore row would only find the first row. 因此,该行只能找到第一行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.