Thursday 25 August 2011

Get selected items Javascript client object model SharePoint 2010


A short example of how to get the selected items and list\library using
Javascript client object model SharePoint 2010.

//Get the Current list\Library. getSelectedList() however only gives you
the Guid\id of the List.
var currentlibGuid = SP.ListOperation.Selection.getSelectedList();

//Get the Current list\Library
var currentLib = web.get_lists().getById(currentlibGuid);

//Get selected Items
var selectedItems = SP.ListOperation.Selection.getSelectedItems(context);

//Get Selected Items count
var count = CountDictionary(selectedItems);
for(var i in selectedItems)
{
//Get the Item
var currentItem = currentLib.getItemById(selectedItems[i].id);
context.load(currentItem);
}

Ads by Google

1 comment:

  1. Nice post. I be taught one thing more difficult on different blogs everyday. It's going to at all times be stimulating to read content material from other writers and practice just a little one thing from their store. I’d prefer to make use of some with the content material on my blog whether you don’t mind. Natually I’ll provide you with a link on your web blog. Thanks for sharing. real money casino

    ReplyDelete