Greetings,
How does one fetch the distinct values in a RadGridDataColumn as formatted via the binding's IValueConverter or StringFormat? The rdGrid.GetDistinctValues(column, true, null) method returns the raw unformatted values.
Is there a clever or easy way to get the formatted values as displayed in the grid?
Thanks
I figured it out. Here's how it can be done:
How does one fetch the distinct values in a RadGridDataColumn as formatted via the binding's IValueConverter or StringFormat? The rdGrid.GetDistinctValues(column, true, null) method returns the raw unformatted values.
Is there a clever or easy way to get the formatted values as displayed in the grid?
Thanks
I figured it out. Here's how it can be done:
var distinctValues = uxGrid.GetDistinctValues(column, true, null); var clip = string.Empty; int count = 0; Func<object, object> formatter; if (column.DataMemberBinding.Converter != null) { formatter = _ => column.DataMemberBinding.Converter.Convert(_, column.DataType, null, CultureInfo.CurrentUICulture); } else if (!string.IsNullOrEmpty(column.DataMemberBinding.StringFormat)) { formatter = _ => string.Format(_.ToString(), column.DataFormatString); } else { formatter = _ => _; } foreach (var value in distinctValues) { clip += formatter(value) + "\n"; count++; } clip = clip.TrimEnd('\n'); Clipboard.SetText(clip);