1

I'm trying to get a list of all available/non selected items in from a MultilistField.

I know you can use this to get the selected items

applicationField.GetItems()

How do I go about getting the list of available items to use?

Thanks!

1 Answer 1

2

Something like this should do the trick:

// get the "Source" string from the template field
var sourceString = applicationField.InnerField.Source;

// get the item from which the field comes from
var currentItem = applicationField.InnerField.Item;

// get selected ids of selected items
var selectedItems = applicationField.TargetIDs;

using (new LanguageSwitcher(currentItem.Language))
{
    // get all the items based on the "Source" string and item
    var allItems = LookupSources.GetItems(currentItem, sourceString);

    // filter out selected from all the items 
    var unselectedItems = allItems.Where(item => !selectedItems.Contains(item.ID));
}

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.