Beispiel #1
0
        public List <IDynamicProperty> GetPropertiesSorted(bool nullValues, ESortBy sortBy, ESortDirection sortDirection)
        {
            //copy and return property list
            var properties = new List <IDynamicProperty>();

            properties = GetProperties(nullValues);

            switch (sortBy)
            {
            case ESortBy.None:
                break;

            case ESortBy.Key:
                if (sortDirection == ESortDirection.Ascending)
                {
                    properties.Sort(new PropertyKeyComparer());
                }
                else
                {
                    properties.Sort(new PropertyKeyComparerDesc());
                }
                break;

            case ESortBy.Value:
                if (sortDirection == ESortDirection.Ascending)
                {
                    properties.Sort(new PropertyValueAsStringComparer());
                }
                else
                {
                    properties.Sort(new PropertyValueAsStringComparerDesc());
                }
                break;

            case ESortBy.ValueAsString:
                if (sortDirection == ESortDirection.Ascending)
                {
                    properties.Sort(new PropertyValueAsStringComparer());
                }
                else
                {
                    properties.Sort(new PropertyValueAsStringComparerDesc());
                }
                break;

            case ESortBy.DisplayName:
                if (sortDirection == ESortDirection.Ascending)
                {
                    properties.Sort(new PropertyDisplayNameComparer());
                }
                else
                {
                    properties.Sort(new PropertyDisplayNameComparerDesc());
                }
                break;

            case ESortBy.Description:
                if (sortDirection == ESortDirection.Ascending)
                {
                    properties.Sort(new PropertyDescriptionComparer());
                }
                else
                {
                    properties.Sort(new PropertyDescriptionComparerDesc());
                }
                break;

            case ESortBy.SortCriteria:
                if (sortDirection == ESortDirection.Ascending)
                {
                    properties.Sort(new PropertySortCriteriaComparer());
                }
                else
                {
                    properties.Sort(new PropertySortCriteriaComparerDesc());
                }
                break;

            case ESortBy.Custom:
                Debug.Assert(false,
                             "For custom sorting use GetPropertiesSorted(bool nullValues, IComparer<IDynamicProperty> comparer) function");
                break;

            default:
                break;
            }

            return(properties);
        }
Beispiel #2
0
 public static void AddDynamicColumns(ColumnView gridView, IDynamicPropertyList propertyList, ESortBy sortBy)
 {
     AddDynamicColumns(gridView, propertyList, sortBy, ESortDirection.Ascending, null, null, true);
 }
Beispiel #3
0
 public static void AddDynamicColumns(ColumnView gridView, IDynamicPropertyList propertyList, ESortBy sortBy,
                                      ESortDirection sortDir, string nullText)
 {
     AddDynamicColumns(gridView, propertyList, sortBy, sortDir, nullText, null, true);
 }
Beispiel #4
0
        private static void AddDynamicColumns(ColumnView gridView, IDynamicPropertyList propertyList, ESortBy sortBy,
                                              ESortDirection sortDir, string nullText, IComparer <IDynamicProperty> comparer, bool allowFilter)
        {
            RepositoryItemTextEdit riteCol = null;

            gridView.BeginDataUpdate();
            int visibleIndexValue = 0;

            foreach (GridColumn column in gridView.Columns)
            {
                if (column.VisibleIndex > visibleIndexValue)
                {
                    visibleIndexValue = column.VisibleIndex;
                }
            }

            if (!string.IsNullOrEmpty(nullText))
            {
                riteCol          = new RepositoryItemTextEdit();
                riteCol.NullText = nullText;
            }

            List <IDynamicProperty> propertyListSorted;

            if (comparer == null)
            {
                propertyListSorted = propertyList.GetPropertiesSorted(true, sortBy, sortDir);
            }
            else
            {
                propertyListSorted = propertyList.GetPropertiesSorted(true, comparer);
            }

            foreach (IDynamicProperty property in propertyListSorted)
            {
                var newColumn = new GridColumn();

                newColumn.Caption   = property.DisplayName;
                newColumn.FieldName = property.Key;
                newColumn.Name      = "col" + property.Key;
                newColumn.OptionsColumn.ReadOnly = property.ReadOnly;
                newColumn.Visible = property.Visible;
                newColumn.ToolTip = property.Description;
                newColumn.OptionsFilter.AllowFilter = allowFilter;
                if (riteCol != null)
                {
                    newColumn.ColumnEdit = riteCol;
                }

                if (property.Visible)
                {
                    visibleIndexValue++;
                    newColumn.VisibleIndex = visibleIndexValue;
                }
                else
                {
                    newColumn.VisibleIndex = -1;
                }

                newColumn.Tag         = property.Key;
                newColumn.UnboundType = GetUnboundType(property);

                //check if column exists
                foreach (GridColumn column in gridView.Columns)
                {
                    Debug.Assert(column.Name != newColumn.Name, "Column with this name exists already");
                }

                gridView.Columns.Add(newColumn);
            }
            gridView.EndDataUpdate();
        }