SHARE
TWEET

Untitled

a guest May 24th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. using Telerik.Sitefinity.Data;
  7. using Telerik.Sitefinity.DynamicModules.Model;
  8. using Telerik.Sitefinity.Model;
  9. using Telerik.Sitefinity;
  10. using Telerik.Sitefinity.Web.Services.Extensibility;
  11.  
  12. namespace SitefinityWebApp.Helpers
  13. {
  14.     public class CustomChoicesCalculatedField : CalculatedProperty
  15.     {
  16.         /// <summary>
  17.         /// What type of data is being returned, must be a simple type or something that is already in the service or marked with [DataContract]
  18.         /// </summary>
  19.         public override Type ReturnType
  20.         {
  21.             get
  22.             {
  23.                 return typeof(ChoiceOption[]);
  24.             }
  25.         }
  26.         /// <summary>
  27.         /// Returns Choice option for Choices fields on the Jobs Dynamic Module
  28.         /// </summary>
  29.         /// <param name="items">Data beeing returned by the oData service</param>
  30.         /// <param name="manager">Current Manager from the service</param>
  31.         /// <returns></returns>
  32.         public override IDictionary<object, object> GetValues(IEnumerable items, IManager manager)
  33.         {
  34.             var ret = new Dictionary<object, object>();
  35.             foreach (IDataItem item in items)
  36.             {
  37.                 var dynamicContent = item as DynamicContent;
  38.                 var choices = dynamicContent.GetValue<ChoiceOption[]>("Features");
  39.                 if (choices != null)
  40.                 {
  41.                     ret.Add(item, choices);
  42.                 }
  43.             }
  44.  
  45.             return ret;
  46.         }
  47.     }
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top