Read ListItem by passing view name

Oct 3, 2011 at 1:40 PM
Edited Oct 3, 2011 at 1:40 PM

 

						 

Dears,

 

I want to get my list items by view name.

How can I do that.

						 <script>
                        	$(document).ready(function()
							{
							        var count=1;
							        $().SPServices({
									   operation: "GetListItems",
									    async: true,
									    listName: "TopMenu",
									    viewName:"AllItems", 
										CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
									    completefunc: function (xData, Status) {
									        $(xData.responseXML).find("[nodeName='z:row']").each(function() {alert($(this).text());
									        var liHtml = "<li><a id=\"menu"+ count +"\" class=\"menu_trigger\" href=\"#\">" + $(this).attr("ows_Title") + "</a></li>";
									        count +=1;
									        $("#topMenu").append(liHtml);
									      });
									    }
									  });
						 });
						 </script>

Oct 4, 2011 at 12:35 AM

If you read over the documentation, it shows you how to set this type of query up.  Here's an excerpt from http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems.aspx

viewName

A string that contains the GUID for the view surrounded by curly braces ({}), which determines the view to use for the default view attributes represented by the queryviewFields, and rowLimit parameters. If this parameter contains an empty string, the default view is used. If the view GUID is supplied, the value of the queryviewFields, or rowLimit parameter overrides the equivalent setting within the view. For example, if the view specified by the viewFieldsparameter has a row limit of 100 rows but the rowLimit parameter contains 1000, then 1,000 rows are returned in the response.

Coordinator
Oct 4, 2011 at 4:03 PM

Note that if you specify any other CAML parameters besides the ViewName, they will override the view settings.

M.

Oct 18, 2012 at 12:39 PM

The following page explains how to extract the GUID for a View

http://www.dhirajranka.com/?p=50

It's the GUID that is the value for viewName