0

I am using a Telerik OrgChart control. I’m basically struggling to extract rendered field from a node. You can add OrgChartRenderedField to each node; this has a property called Label.

Each OrgChartRenderedField per node is contained within an OrgChartRenderedFieldCollection

public class OrgChartRenderedFieldCollection : System.Collections.Generic.List<OrgChartRenderedField>
Member of Telerik.Web.UI

It has a method called find()

public T Find(System.Predicate<T> match)
Member of System.Collections.Generic.List<T>

Summary: Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire System.Collections.Generic.List.

Parameters: match: The System.Predicate delegate that defines the conditions of the element to search for.

Returns: The first element that matches the conditions defined by the specified predicate, if found; otherwise, the default value for type T.

Exceptions: System.ArgumentNullException: match is null.

The main problem I have is that I can’t figure out how to search the collection for specific OrgChartRenderedField object where the Label = ‘Some text’ Appreciate it’s a third party plugin; hoping knowing the types of objects somebody can give me a suggestion. Thanks.

Andyww
  • 209
  • 3
  • 13
  • 3
    That method is part of `List`, it should be as simple as `list.Find(o => o.Label == "Some Text")` – DavidG Aug 23 '16 at 13:18
  • See [this answer](http://stackoverflow.com/a/556442/4416750) for an explanation of a predicate delegate. – Lews Therin Aug 23 '16 at 13:27

1 Answers1

1

The Find method is part of List<T>. The usage requires a delegate, the simplest way is probably to use a lambda, something like this:

var item = list.Find(o => o.Label == "Some Text");
DavidG
  • 113,891
  • 12
  • 217
  • 223