Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharepoint 2010 Client Object Model - Get the name of the current list

I'm trying to create a simple custom action button for the Ribbon menu in Sharepoint 2010.

I want to keep it generic, so no hard coding of library names etc.

How can I find out the name of the current list being viewed? I would imagine that this is possible without having to parse it from the Url.

Many thanks!

like image 930
John Mc Avatar asked Sep 17 '11 23:09

John Mc


People also ask

How to retrieve list items in c#?

To return items from a list, use the GetItemById() method to return a single item, or the GetItems(CamlQuery) method to return multiple items. You then use the Load<T>(T, []) method to attain list item objects that represent the items.

What is ClientContext in SharePoint?

Remarks. Use the ClientContext class to return context information about such objects as the current web application, site, site collection, or server version. The Document library templates sample app for SharePoint includes an example of how to use this object.

What is JSOM in SharePoint?

JavaScript Object Model (JSOM) is a great value addition for SharePoint development. The articles teach how you can use JSOM script in your application from Clint Browser itself. You can use ECMA Script Client Object Model (JSOM) to retrieve, update, and manage data in SharePoint.


1 Answers

It took a bit of digging, but I found the answer in the end. You can get the Id of the list in Javascript by using:

//Get the Id of the list
var listId = SP.ListOperation.Selection.getSelectedList();
like image 64
John Mc Avatar answered Oct 23 '22 19:10

John Mc