0

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?

enter image description here

1

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
}

Here is an example of it in use

  • 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
0

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);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.