Isaac
asked on
jquery increment
Hi All,
I have two lists called "Analyst" and "Log".
I am trying to find out how many times each analyst was assigned an assignment and represent the data in a google chart table like so "https://developers.google.com/chart/interactive/docs/gallery/table".
My actual production list contains 2000+ items.
I want to use jquery to accomplish the counting but I'm sort of stuck.
Here's what I have so far:
Does what I have so far look right? For some reason, it seems like it won't work because, anArray[x] is never initialized to zero.
Any ideas/suggestions/comments would be great.
My analyst list:
http://isaac.issharepoint.com/Lists/Analyst/AllItems.aspx
My log list:
http://isaac.issharepoint.com/Lists/Log/AllItems.aspx
Thanks!
I have two lists called "Analyst" and "Log".
I am trying to find out how many times each analyst was assigned an assignment and represent the data in a google chart table like so "https://developers.google.com/chart/interactive/docs/gallery/table".
My actual production list contains 2000+ items.
I want to use jquery to accomplish the counting but I'm sort of stuck.
Here's what I have so far:
var anArray = new Array();
var anIndex=[];
//push names of analyst into an array to use later
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Analyst",
CAMLViewFields: "<ViewFields><FieldRef Name='Title'></FieldRef></ViewFields>",
CAMLQuery: "<Query><OrderBy><FieldRef Name='Title' /></OrderBy></Query>",
completefunc: function (xData, Status) {
//alert(xData.responseXML.xml);
$(xData.responseXML).SPFilterNode("z:row").each(function() {
anArray.push($(this).attr("ows_Title"));
});
}
//initialize "anIndex" array to zero
});
$().SPServices({
operation: "GetListItems",
async: false,
listName: "Log",
CAMLViewFields: "<ViewFields><FieldRef Name='Days'></FieldRef><FieldRef Name='Analyst'></FieldRef></ViewFields>",
CAMLQuery: "<Query><OrderBy><FieldRef Name='Days' /></OrderBy></Query>",
completefunc: function (xData, Status) {
//alert(xData.responseXML.xml);
$(xData.responseXML).SPFilterNode("z:row").each(function() {
//As you loop through the array, if 'Analyst' name equals what's in the array, then increment
for (var x=0; x<anArray.length; x++)
{
if ($(this).attr("ows_Analyst") == anArray[x])
{
anArray[x] += 1;
}
}
});
}
});
Does what I have so far look right? For some reason, it seems like it won't work because, anArray[x] is never initialized to zero.
Any ideas/suggestions/comments
My analyst list:
http://isaac.issharepoint.com/Lists/Analyst/AllItems.aspx
My log list:
http://isaac.issharepoint.com/Lists/Log/AllItems.aspx
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
http://isaac.issharepoint.com/Shared%20Documents/pieChart.aspx
Here's the code:
Open in new window