Is there a way to retrieve the selected list item title/name? For example if I click an item say "Distributor" in custom list, how can I get this title in a string or variable?
If you mean doing it through code you could use the getSelectedItems() method:
var items = SP.ListOperation.Selection.getSelectedItems(context);
You could then just iterate through the items and get the desired attribute:
for(i in items)
{
// do something
}
-
This is the only approach. There is no equivalent to this method on the server side as the selection is completely done client side in SharePoint. – Vardhaman Deshpande Aug 6 '12 at 15:12
You can use CAML and SPQuery:
private SPListCollection GetDecriptionItems(SPList list)
{
SPQuery query = new SPQuery()
{
Query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Distributor'></Value></Eq></Where><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy>"
};
return list.GetItems(query);
}