How to get values of filter (displayed in the filtering control)

Let's assume you want to create your own filter, so you need values by which a field can be filtered which are all the values displayed in the filtering control.



How can you get it?

This can be done by using the following code (in this code we get the list of values for the first field on the component X-axis of the dataCubeGrid1):
if (dataCubeGrid1.Source != null && dataCubeGrid1.Source.DataSource != null)

         {
             DataCube dataCube = dataCubeGrid1.Source;
             Field field = dataCubeGrid1.Source.XDimensions[0];
             OlapExpressionSite site = new OlapExpressionSite();
             object dataSource = dataCube.DataSource;
             if (dataCube.JointFields != null)
             dataSource = new 
SourceWrapper(dataSource, dataCube.JointFields);
             IEnumerable en = ClientOlapEngine.GetEnumerable(dataSource);
             List<object> valueList = new List<object>();
             if (en != null)
             {
                 foreach (object record in en)
                 {
                     site.Record = record;
                     object value = 
ClientOlapEngine.CalculateValue(field.ExpressionObject, site).ToString();
                     if (!valueList.Contains(value))
                     {
                         bool c = false;
                         site.Value = value;
                         c = field.Filter.IsFiltered(value, site);
                         valueList.Add(value);
                     }
                 }
             }
                StringBuilder sb = new StringBuilder();
                foreach (object item in valueList)
                {
                    sb.AppendLine("[" + item.ToString() + "]");
                }
                System.Windows.Forms.MessageBox.Show(sb.ToString());
            }

Add Feedback