some list items not showing

I have the jQuery code below that is supposed to display all the items in a list but it only shows 28 of 65 list items.  Anybody know why that is?


<style>
	.tdBackGround {
	background-image: url(../image/CSSGradient.gif); 
	BORDER-BOTTOM: #bfbfbf 1px solid; 
	text-align: center; 
	border-left: #bfbfbf 1px solid; 
	background-repeat: repeat-x; 
	white-space: nowrap; 
	color: white; 
	border-top: #bfbfbf 1px solid; 
	font-weight: bold; 
	border-right: #bfbfbf 1px solid;
}
</style>


<table id="DeliverableTbl" cellspacing="2" cellpadding="2" style="text-align:left;" width="100%" align="center">
				<tr style="font-family:verdana;font-size:12px;font-weight:bold">
								<td class="tdBackGround">Edit</td>
								<td class="tdBackGround">Deliverable Name</td>
								<td class="tdBackGround">Performer</td>
								<td class="tdBackGround">CNID</td>
								<td class="tdBackGround">FY</td>
								<td class="tdBackGround">Activiy</td>
								<td class="tdBackGround">Project</td>
								<td class="tdBackGround">Product</td>
								<td class="tdBackGround">Govt Lead</td>
								<td class="tdBackGround">Performer POCs</td>
								<td class="tdBackGround">Description</td>
								<td class="tdBackGround">Start Date</td>
								<td class="tdBackGround">End Date</td>
								<td class="tdBackGround">Previous End Date(s)</td>
								<td class="tdBackGround">Completion Date</td>
								<td class="tdBackGround">Planned</td>
								<td class="tdBackGround">Staff Months</td>
								<td class="tdBackGround">Function</td>
								<td class="tdBackGround">Status</td>	
								<td class="tdBackGround">Contract</td>																
				</tr>
</table>
<script type="text/javascript" src="../js/jquery-1.8.2.min.js" language="javascript"></script>
<script type="text/javascript" src="../js/jquery.SPServices-0.7.2.min.js" language="javascript"></script>
<script type="text/javascript" src="../js/jquery-ui-LatestVersion.js" language="javascript"></script>
<link rel="stylesheet" type="text/css" href="../Style/jquery-ui-LatestVersion.css">
<style>
	.complete{
	color:green;
	font-family:arial
}

	.inProgress{
	color:gray;
	font-family:arial
}

	.notStarted{
	color:blue;
	font-family:arial	
}
</style>

<script type="text/javascript">

$(document).ready(function() {

var currSiteUrl = $().SPServices.SPGetCurrentSite();


 var soapEnv1 =
        "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>" +
            "<soapenv:Body>" +
                "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
                    "<listName>Deliverables</listName>" + 
                    "<viewFields>" +
                        "<ViewFields>" +
                        "</ViewFields>" +
                    "</viewFields>" +
                "</GetListItems>" +
            "</soapenv:Body>" +
        "</soapenv:Envelope>";
  
  
        $.ajax(
		{
			url: currSiteUrl + "/_vti_bin/lists.asmx",
			async: true,
			type: "POST",
			dataType: "xml",
			data: soapEnv1,
			complete: GetDeliverableData,
			contentType: "text/xml; charset=\"utf-8\""
		});
});
	

function GetDeliverableData(xData,status) 
{
//alert(xData.responseXML.xml);
	var statusColor="";
	$(xData.responseXML).find("z\\:row").each(function() 
	{  	

		$("#DeliverableTbl").append("<tr><td><a href=/editDeliverable.aspx?cid="+checkForNaN($(this).attr("ows_ID"))+"><img src='../image/edit.ico' title='Edit' height='25px' width='25px' border='0'></a></td><td>"+checkForUndefined($(this).attr("ows_Title"))+"</td><td>"+checkForUndefined($(this).attr("ows_Performer"))+"<td>"+checkForUndefined(parseInt($(this).attr("ows_CNID")))+"</td><td>"+checkForUndefined($(this).attr("ows_FY"))+"</td><td>"+checkForUndefined($(this).attr("ows_Activity"))+"</td><td>"+checkForUndefined($(this).attr("ows_Project"))+"</td><td>"+checkForUndefined($(this).attr("ows_Product"))+"</td><td>"+checkForUndefined($(this).attr("ows_GovtLead"))+"</td><td>"+checkForUndefined($(this).attr("ows_PerformerPOCs"))+"</td><td>"+checkForUndefined($(this).attr("ows_Description"))+"</td><td>"+checkForUndefined($(this).attr("ows_StartDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_EndDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_PreviousDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_CompletionDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_Planned"))+"</td><td>"+checkForUndefined($(this).attr("ows_StaffMonths"))+"</td><td>"+checkForUndefined($(this).attr("ows_Function"))+"</td><td>"+checkForUndefined($(this).attr("ows_Status"))+"</td><td>"+checkForUndefined($(this).attr("ows_Contracts"))+"</td></tr>");
	});
}

function checkForUndefined(x){
  return x === undefined ? "" : x;
}

function checkForNaN(x) {
  return x === NaN ? "" : x;
}

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
</script>

Open in new window

LVL 5
IsaacSharePoint Client Side DeveloperAsked:
Who is Participating?
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
Hi,

I downloaded the Fiddler tool but did not understand totally what was going on.  It seems like a useful tool though.

I modified my code and now all my data is being returned.

function FilterDeliverableData(statusVar)
{
	var i = 0;
	
	$().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Deliverables",
    CAMLViewFields: "<ViewFields></ViewFields>",
	CAMLRowLimit: 0,
	CAMLQuery:"<Query><Where><Eq><FieldRef Name='Status' /><Value Type='Text'>"+statusVar+"</Value></Eq></Where></Query>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {  
	if ($(this).attr("ows_Status")=="Complete")
		{
				statusColor="complete";
		}
		else if ($(this).attr("ows_Status")=="Not Started")
		{
				statusColor="notStarted";
		}
		else if ($(this).attr("ows_Status")=="In Progress")
		{
				statusColor="inProgress";
		}
			$("#DeliverableTbl").append("<tr class='"+statusColor+"'><td><a href=http://issharepoint.com/EE/Site%20Pages/editDeliverable.aspx?cid="+checkForNaN($(this).attr("ows_ID"))+">Edit</td><td>"+checkForUndefined($(this).attr("ows_Title"))+"</td><td>"+checkForUndefined(parseInt($(this).attr("ows_CNID")))+"</td><td>"+checkForUndefined($(this).attr("ows_FY"))+"</td><td>"+checkForUndefined($(this).attr("ows_Activity"))+"</td><td>"+checkForUndefined($(this).attr("ows_Project"))+"</td><td>"+checkForUndefined($(this).attr("ows_Product"))+"</td><td>"+checkForUndefined($(this).attr("ows_GovtLead"))+"</td><td>"+checkForUndefined($(this).attr("ows_PerformerPOCs"))+"</td><td>"+checkForUndefined($(this).attr("ows_Description"))+"</td><td>"+checkForUndefined($(this).attr("ows_StartDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_EndDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_PreviousDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_CompletionDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_Planned"))+"</td><td>"+checkForUndefined($(this).attr("ows_StaffMonths"))+"</td><td>"+checkForUndefined($(this).attr("ows_Function"))+"</td><td>"+checkForUndefined($(this).attr("ows_Status"))+"</td><td>"+checkForUndefined($(this).attr("ows_Contracts"))+"</td></tr>");

      });

     }

  });
}	
	
	
function RenderDeliverableData()
{
	
	$().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Deliverables",
    CAMLViewFields: "<ViewFields></ViewFields>",
	CAMLRowLimit: 0,
    CAMLQuery:"<Query></Query>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() { 
	if ($(this).attr("ows_Status")=="Complete")
		{
				statusColor="complete";
		}
		else if ($(this).attr("ows_Status")=="Not Started")
		{
				statusColor="notStarted";
		}
		else if ($(this).attr("ows_Status")=="In Progress")
		{
				statusColor="inProgress";
		}
			$("#DeliverableTbl").append("<tr class='"+statusColor+"'><td><a href=http://issharepoint.com/EE/Site%20Pages/editDeliverable.aspx?cid="+checkForNaN($(this).attr("ows_ID"))+">Edit</td><td>"+checkForUndefined($(this).attr("ows_Title"))+"</td><td>"+checkForUndefined(parseInt($(this).attr("ows_CNID")))+"</td><td>"+checkForUndefined($(this).attr("ows_FY"))+"</td><td>"+checkForUndefined($(this).attr("ows_Activity"))+"</td><td>"+checkForUndefined($(this).attr("ows_Project"))+"</td><td>"+checkForUndefined($(this).attr("ows_Product"))+"</td><td>"+checkForUndefined($(this).attr("ows_GovtLead"))+"</td><td>"+checkForUndefined($(this).attr("ows_PerformerPOCs"))+"</td><td>"+checkForUndefined($(this).attr("ows_Description"))+"</td><td>"+checkForUndefined($(this).attr("ows_StartDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_EndDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_PreviousDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_CompletionDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_Planned"))+"</td><td>"+checkForUndefined($(this).attr("ows_StaffMonths"))+"</td><td>"+checkForUndefined($(this).attr("ows_Function"))+"</td><td>"+checkForUndefined($(this).attr("ows_Status"))+"</td><td>"+checkForUndefined($(this).attr("ows_Contracts"))+"</td></tr>");

      });

     }

  });
}

Open in new window


Thanks for all you help.
0
 
GaryCommented:
Are you sure the full data is returned?
In the each function is it running the 65 times and just not appending?
0
 
Miguel OzSoftware EngineerCommented:
Can you post the result of  $(xData.responseXML).find("z\\:row").length?
If this number  = 28 then either your response (coming from web service) or selector expression(("z\\:row") is not correct.

If your xml response is correct,  please post it (xData.responseXML)and what nodes you are interested to fetch. Usually the selector only needs the node element name  to fetch the correct nodes.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
IsaacSharePoint Client Side DeveloperAuthor Commented:
It's 28 which is wrong.

What''s the best way to provide the xData.responseXML?
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
The number is actually 30 which is still wrong.
0
 
Miguel OzSoftware EngineerCommented:
As per my previous comment: Please post your xData.responseXML content and check that you have the 65 entries inside the xml string. (Copy the string to text file and search there for the element node you are after. If the xml string contains the 65 entries then selector expression(("z\\:row") is incorrect else your web service response is not providing the right answer and you must fix your web service code.
Which xml node are you after in the response xml?
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
I'm after about 20 nodes:
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
how do I get the xData.responseXML into a text file?

I tried the following but no go:

<label id="test"></label>

.
.
.
.$("#test").append(xData.responseXML.xml);
0
 
Miguel OzSoftware EngineerCommented:
Just put a breakpoint in the JS code on this line:
$(xData.responseXML).find("z\\:row").each(function()

when debugger stops at this breakpoint:
Press Shift+F9, quick watch dialog shows up with expresion set to "xData.responseXML"
Copy the value shown on dialog  and paste to a text file.
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
Hi,

I tried the break before and after the JS code, $(xData.responseXML).find("z\\:row").each(function(), but I kept getting an error about it being outside the loop.

function GetDeliverableData(xData,status) 
{

	var statusColor="";
	
	$(xData.responseXML).find("z\\:row").each(function() 
	{  	
break;

Open in new window

0
 
Miguel OzSoftware EngineerCommented:
you do not need break statement, if you a running VS, just press F9 on the line and VS will add a break point for you. (if you are not running in VS add break at line 5)
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
Sorry for the late response.  I am not using VS so I added the break at line 5 and got the following error:
error
Also, here's my sp site. I finished creating it so you can see.  If you compare the page and the document library, you'll see that it's not rendering.

http://issharepoint.com/EE/Site%20Pages/DeliverWebpart.aspx
0
 
Miguel OzSoftware EngineerCommented:
Ok the object node element is "z:row". try  replacing:
$(xData.responseXML).find("z\\:row").each(function()
with
$(xData.responseXML).find("z\\:row, row").each(function()

If the above fails then your web service may not be returning the correct number of objects. Build yourself a client win form that calls the web service and captures the response in a memo box. For example:
http://www.sitepoint.com/net-web-services-5-steps/

Which browser are you using? IE, Chrome.
Is there any particular reason for using xml instead of JSON?

Note: If you need further help I need the xml response with your valid parameters or add a button on your page that calls the web service with the parameters of the win form app so that we are absolutely sure your web service is returning  the right amount of objects.
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
Hi,

I'll try your suggestions.  I'm using IE 8.

>>Is there any particular reason for using xml instead of JSON?<<
I just learned about JSON last week and understand it but not sure how to use it in this instance.  Please, how can I use JSON in this instance?  Thanks!
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
>>Note: If you need further help I need the xml response with your valid parameters or add a button on your page that calls the web service with the parameters of the win form app so that we are absolutely sure your web service is returning  the right amount of objects.<<

Could you please give me step by step guidance on this?  How can I get you the xml response?  Below is my code if that would help...


<style>
	.tdBackGround {
	background-image: url(http://issharepoint.com/EE/image/cssgradient.gif); 
	BORDER-BOTTOM: #bfbfbf 1px solid; 
	text-align: center; 
	border-left: #bfbfbf 1px solid; 
	background-repeat: repeat-x; 
	white-space: nowrap; 
	color: white; 
	border-top: #bfbfbf 1px solid; 
	font-weight: bold; 
	border-right: #bfbfbf 1px solid;
}
</style>


<table id="DeliverableTbl" cellspacing="2" cellpadding="2" style="text-align:left;" width="100%" align="center">
				<tr style="font-family:verdana;font-size:12px;font-weight:bold">
								<td class="tdBackGround">Edit</td>
								<td class="tdBackGround">Deliverable Name</td>
								<td class="tdBackGround">CNID</td>
								<td class="tdBackGround">FY</td>
								<td class="tdBackGround">Activiy</td>
								<td class="tdBackGround">Project</td>
								<td class="tdBackGround">Product</td>
								<td class="tdBackGround">Govt Lead</td>
								<td class="tdBackGround">Performer POCs</td>
								<td class="tdBackGround">Description</td>
								<td class="tdBackGround">Start Date</td>
								<td class="tdBackGround">End Date</td>
								<td class="tdBackGround">Previous End Date(s)</td>
								<td class="tdBackGround">Completion Date</td>
								<td class="tdBackGround">Planned</td>
								<td class="tdBackGround">Staff Months</td>
								<td class="tdBackGround">Function</td>
								<td class="tdBackGround">Status</td>	
								<td class="tdBackGround">Contracts</td>																
				</tr>
</table>
<script type="text/javascript" src="http://issharepoint.com/EE/js/jquery-1.8.2.min.js" language="javascript"></script>
<script type="text/javascript" src="http://issharepoint.com/EE/js/jquery.SPServices-0.7.2.min.js" language="javascript"></script>
<script type="text/javascript" src="http://issharepoint.com/EE/js/jquery-ui-LatestVersion.js" language="javascript"></script>
<link rel="stylesheet" type="text/css" href="http://issharepoint.com/EE/Styles/jquery-ui-LatestVersion.css">
<style>
	.complete{
	color:green;
	font-family:arial
}

	.inProgress{
	color:gray;
	font-family:arial
}

	.notStarted{
	color:blue;
	font-family:arial	
}
</style>

<script type="text/javascript">

$(document).ready(function() {
//alert("Hello");
var currSiteUrl = $().SPServices.SPGetCurrentSite();
//alert(currSiteUrl);
var status = getUrlVars()["status"];
//var qry = "<Query><Where><Eq><FieldRef Name='ows_Status' /><Value Type='Lookup'>"+status+"</Value></Eq></Where></Query>";	
 
 if (status == "Complete" || status == "In Progress" || status == "Not Started")
 {
 var soapEnv1 =
        "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>" +
            "<soapenv:Body>" +
                "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
                    "<listName>Deliverables</listName>" + 
                    	"<query><Query><Where><Eq><FieldRef Name='Status' /><Value Type='Text'>"+status+"</Value></Eq></Where></Query></query>" +                       
                    "<viewFields>" +
                        "<ViewFields>" +
                        "</ViewFields>" +
                    "</viewFields>" +
                "</GetListItems>" +
            "</soapenv:Body>" +
        "</soapenv:Envelope>";
  }
  else
  {  
 var soapEnv1 =
        "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>" +
            "<soapenv:Body>" +
                "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
                    "<listName>Deliverables</listName>" + 
                    "<viewFields>" +
                        "<ViewFields>" +
                        "</ViewFields>" +
                    "</viewFields>" +
                "</GetListItems>" +
            "</soapenv:Body>" +
        "</soapenv:Envelope>";
  
  }
        $.ajax(
		{
			url: currSiteUrl + "/_vti_bin/lists.asmx",
			async: true,
			type: "POST",
			dataType: "xml",
			data: soapEnv1,
			complete: GetDeliverableData,
			contentType: "text/xml; charset=\"utf-8\""
		});
});
	

function GetDeliverableData(xData,status) 
{
//alert(xData.responseXML.xml);
	var statusColor="";
	//break;
	$(xData.responseXML).find("z\\:row, row").each(function() 
	{  	

		if ($(this).attr("ows_Status")=="Complete")
		{
				statusColor="complete";
		}
		else if ($(this).attr("ows_Status")=="Not Started")
		{
				statusColor="notStarted";
		}
		else if ($(this).attr("ows_Status")=="In Progress")
		{
				statusColor="inProgress";
		}
			$("#DeliverableTbl").append("<tr class='"+statusColor+"'><td><a href=http://issharepoint.com/EE/Site%20Pages/editDeliverable.aspx?cid="+checkForNaN($(this).attr("ows_ID"))+">Edit</td><td>"+checkForUndefined($(this).attr("ows_Title"))+"</td><td>"+checkForUndefined(parseInt($(this).attr("ows_CNID")))+"</td><td>"+checkForUndefined($(this).attr("ows_FY"))+"</td><td>"+checkForUndefined($(this).attr("ows_Activity"))+"</td><td>"+checkForUndefined($(this).attr("ows_Project"))+"</td><td>"+checkForUndefined($(this).attr("ows_Product"))+"</td><td>"+checkForUndefined($(this).attr("ows_GovtLead"))+"</td><td>"+checkForUndefined($(this).attr("ows_PerformerPOCs"))+"</td><td>"+checkForUndefined($(this).attr("ows_Description"))+"</td><td>"+checkForUndefined($(this).attr("ows_StartDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_EndDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_PreviousDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_CompletionDate"))+"</td><td>"+checkForUndefined($(this).attr("ows_Planned"))+"</td><td>"+checkForUndefined($(this).attr("ows_StaffMonths"))+"</td><td>"+checkForUndefined($(this).attr("ows_Function"))+"</td><td>"+checkForUndefined($(this).attr("ows_Status"))+"</td><td>"+checkForUndefined($(this).attr("ows_Contracts"))+"</td></tr>");
	});
}

function checkForUndefined(x){
  return x === undefined ? "" : x;
}

function checkForNaN(x) {
  return x === NaN ? "" : x;
}

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
</script>

Open in new window

0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
>>$(xData.responseXML).find("z\\:row, row").each(function() <<
Still get the same result with the change
0
 
Miguel OzSoftware EngineerCommented:
Read the previous sitepoint link steps 2, 3 and 4.  (All detailed steps are there the only difference is that instead of a grid you can use a label to display the xml results (encoding the results of course))
If you can not make the test app:
1) Use Fiddler tool to capture the AJAX response and post it back checking that server is returning the number of z:row nodes you expect.
2) Add a button to your test page and state how many z:row nodes you are expecting and which browser you are testing. (I use only IE and FF)
0
 
IsaacSharePoint Client Side DeveloperAuthor Commented:
I did not use the soap version and solved my problem.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.