Solved

some list items not showing

Posted on 2013-06-30
18
380 Views
Last Modified: 2013-07-07
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

0
Comment
Question by:Isaac
  • 11
  • 6
18 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39288880
Are you sure the full data is returned?
In the each function is it running the 65 times and just not appending?
0
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 39288921
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
 
LVL 5

Author Comment

by:Isaac
ID: 39288956
It's 28 which is wrong.

What''s the best way to provide the xData.responseXML?
0
 
LVL 5

Author Comment

by:Isaac
ID: 39288959
The number is actually 30 which is still wrong.
0
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 39288961
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
 
LVL 5

Author Comment

by:Isaac
ID: 39288980
I'm after about 20 nodes:
0
 
LVL 5

Author Comment

by:Isaac
ID: 39289006
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
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 39289195
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
 
LVL 5

Author Comment

by:Isaac
ID: 39289683
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
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 35

Expert Comment

by:Miguel Oz
ID: 39289847
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
 
LVL 5

Author Comment

by:Isaac
ID: 39291508
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
 
LVL 35

Assisted Solution

by:Miguel Oz
Miguel Oz earned 500 total points
ID: 39291796
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
 
LVL 5

Author Comment

by:Isaac
ID: 39291816
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
 
LVL 5

Author Comment

by:Isaac
ID: 39291826
>>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
 
LVL 5

Author Comment

by:Isaac
ID: 39291832
>>$(xData.responseXML).find("z\\:row, row").each(function() <<
Still get the same result with the change
0
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 39292108
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
 
LVL 5

Accepted Solution

by:
Isaac earned 0 total points
ID: 39295216
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
 
LVL 5

Author Closing Comment

by:Isaac
ID: 39305109
I did not use the soap version and solved my problem.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now