.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Post New Resource Bookmark and Share   

Display all list iteam Using Sharepoint Client Object Model

Posted By:Sagar Pardeshi       Posted Date: September 21, 2013    Points: 40    Category:    URL: http://www.dotnetspark.com  

Using Sharepoint Client Object Model Access List All item and display using ECMA Scrpit
 





<script src="/_layouts/SP.js" type="text/ecmascript"></script>
<script type="text/ecmascript">

function ViewItem()
{
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle('Testlist');

var query = SP.CamlQuery.createAllItemsQuery();
allItems = list.getItems(query);
context.load(allItems, 'Include(Title,Department)');

context.executeQueryAsync(Function.createDelegate(this, this.success), Function.createDelegate(this, this.failed));
}

function success() {

var TextFiled = "";
var ListEnumerator = this.allItems.getEnumerator();

while(ListEnumerator.moveNext())
{
var currentItem = ListEnumerator.get_current();
TextFiled  += currentItem.get_item('Title') + '-' +currentItem.get_item('Department') + '\n';
}
alert(TextFiled);
}

function failed(sender, args) {
alert("failed. Message:" + args.get_message());
}

</script>

<a href="#" onclick="Javascript:ViewItem();">View Items</a>




     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend