Ejemplo n.º 1
0
 private void RefreshColumn(ColumnInfoNodeWrapper frameColumn, GridColumn column)
 {
     column.Caption = frameColumn.Caption;
     if (string.IsNullOrEmpty(column.Caption))
     {
         column.Caption = column.FieldName;
     }
     if (!string.IsNullOrEmpty(frameColumn.DisplayFormat))
     {
         column.DisplayFormat.FormatString = frameColumn.DisplayFormat;
         column.DisplayFormat.FormatType = FormatType.Custom;
         column.GroupFormat.FormatString = frameColumn.DisplayFormat;
         column.GroupFormat.FormatType = FormatType.Custom;
     }
     column.GroupIndex = frameColumn.GroupIndex;
     column.SortIndex = frameColumn.SortIndex;
     column.SortOrder = frameColumn.SortOrder;
     column.Width = frameColumn.Width;
     column.VisibleIndex = frameColumn.VisibleIndex;
     column.SummaryItem.SummaryType = frameColumn.SummaryType;
 }
Ejemplo n.º 2
0
        public GridColumn AddColumn(ColumnInfoNodeWrapper columnInfo, Type objectType, ListViewInfoNodeWrapper model)
        {
            ColumnInfoNodeWrapper frameColumn = model.Columns.FindColumnInfo(columnInfo.PropertyName);
            if (frameColumn == null)
            {
                model.Columns.Node.AddChildNode(columnInfo.Node);
            }
            var column = new GridColumn();

            GridView.Columns.Add(column);
            var customArgs = new CustomCreateColumnEventArgs(column, columnInfo, repositoryFactory);
            if (!customArgs.Handled)
            {
                IMemberInfo memberInfo = XafTypesInfo.Instance.FindTypeInfo(objectType).FindMember(columnInfo.PropertyName);
                if (memberInfo != null)
                {
                    column.FieldName = memberInfo.BindingName;
                    if (memberInfo.MemberType.IsEnum)
                    {
                        column.SortMode = ColumnSortMode.Value;
                    }
                    else if (!SimpleTypes.IsSimpleType(memberInfo.MemberType))
                    {
                        column.SortMode = ColumnSortMode.DisplayText;
                    }
                    column.FilterMode = SimpleTypes.IsClass(memberInfo.MemberType) ? ColumnFilterMode.DisplayText : ColumnFilterMode.Value;
                }
                else
                {
                    column.FieldName = columnInfo.PropertyName;
                }

                RefreshColumn(columnInfo, column);
                if (memberInfo != null)
                {
                    if (repositoryFactory != null)
                    {
                        bool isGranted = DataManipulationRight.CanRead(objectType, columnInfo.PropertyName, null,
                                                                       ((ListView)View).CollectionSource);
                        RepositoryItem repositoryItem = repositoryFactory.CreateRepositoryItem(!isGranted, new DetailViewItemInfoNodeWrapper(columnInfo.Node), objectType);
                        if (repositoryItem != null)
                        {
                            gridControl.RepositoryItems.Add(repositoryItem);
                            column.ColumnEdit = repositoryItem;
                            column.OptionsColumn.AllowEdit = IsDataShownOnDropDownWindow(repositoryItem) ? true : model.AllowEdit;
                            column.AppearanceCell.Options.UseTextOptions = true;
                            column.AppearanceCell.TextOptions.HAlignment = WinAlignmentProvider.GetAlignment(memberInfo.MemberType);
                            repositoryItem.ReadOnly |= !model.AllowEdit;
                            if ((repositoryItem is ILookupEditRepositoryItem) && ((ILookupEditRepositoryItem)repositoryItem).IsFilterByValueSupported)
                            {
                                column.FilterMode = ColumnFilterMode.Value;
                            }
                            if ((repositoryItem is RepositoryItemPictureEdit) && (((RepositoryItemPictureEdit)repositoryItem).CustomHeight > 0))
                            {
                                GridView.OptionsView.RowAutoHeight = true;
                            }
                        }
                    }
                    if ((column.ColumnEdit == null) && !typeof(IList).IsAssignableFrom(memberInfo.MemberType))
                    {
                        column.OptionsColumn.AllowEdit = false;
                        column.FieldName = GetDisplayablePropertyName(columnInfo.PropertyName, XafTypesInfo.Instance.FindTypeInfo(objectType));
                    }
                }

            }
            if (!gridControl.IsLoading && gridView.DataController.Columns.GetColumnIndex(column.FieldName) == -1)
            {
                gridView.DataController.RePopulateColumns();
            }
            return column;
        }
Ejemplo n.º 3
0
 public ColumnCreatedEventArgs(LayoutViewColumn column, ColumnInfoNodeWrapper columnInfo) {
     this.column = column;
     this.columnInfo = columnInfo;
 }
Ejemplo n.º 4
0
 public LayoutViewColumn AddColumn(ColumnInfoNodeWrapper columnInfo) {
     if (columnsProperties.ContainsValue(columnInfo.PropertyName)) {
         throw new ArgumentException(string.Format(SystemExceptionLocalizer.GetExceptionMessage(ExceptionId.GridColumnExists), columnInfo.PropertyName), "ColumnInfo");
     }
     ColumnInfoNodeWrapper frameColumn = Model.Columns.FindColumnInfo(columnInfo.PropertyName);
     if (frameColumn == null) {
         Model.Columns.Node.AddChildNode(columnInfo.Node);
     }
     LayoutViewColumn column = new LayoutViewColumn();
     columnsProperties.Add(column, columnInfo.PropertyName);
     LayoutView.Columns.Add(column);
     CustomCreateColumnEventArgs customArgs = new CustomCreateColumnEventArgs(column, columnInfo, repositoryFactory);
     OnCustomCreateColumn(customArgs);
     if (!customArgs.Handled) {
         IMemberInfo memberDescriptor = XafTypesInfo.Instance.FindTypeInfo(ObjectType).FindMember(columnInfo.PropertyName);
         if (memberDescriptor != null) {
             column.FieldName = memberDescriptor.BindingName;
             if (memberDescriptor.MemberType.IsEnum) {
                 column.SortMode = ColumnSortMode.Value;
             } else if (!SimpleTypes.IsSimpleType(memberDescriptor.MemberType)) {
                 column.SortMode = ColumnSortMode.DisplayText;
             }
             if (SimpleTypes.IsClass(memberDescriptor.MemberType)) {
                 column.FilterMode = ColumnFilterMode.DisplayText;
             } else {
                 column.FilterMode = ColumnFilterMode.Value;
             }
         } else {
             column.FieldName = columnInfo.PropertyName;
         }
         RefreshColumn(columnInfo, column);
         if (memberDescriptor != null) {
             if (repositoryFactory != null) {
                 RepositoryItem repositoryItem = repositoryFactory.CreateRepositoryItem(false, new DetailViewItemInfoNodeWrapper(columnInfo.Node), ObjectType);
                 if (repositoryItem != null) {
                     grid.RepositoryItems.Add(repositoryItem);
                     column.ColumnEdit = repositoryItem;
                     column.OptionsColumn.AllowEdit = IsDataShownOnDropDownWindow(repositoryItem) ? true : editMode != EditMode.ReadOnly;
                     repositoryItem.ReadOnly |= editMode != EditMode.Editable;
                     if ((repositoryItem is ILookupEditRepositoryItem) && ((ILookupEditRepositoryItem)repositoryItem).IsFilterByValueSupported) {
                         column.FilterMode = ColumnFilterMode.Value;
                     }
                 }
             }
             if ((column.ColumnEdit == null) && !typeof(IList).IsAssignableFrom(memberDescriptor.MemberType)) {
                 column.OptionsColumn.AllowEdit = false;
                 column.FieldName = GetDisplayablePropertyName(columnInfo.PropertyName);
             }
         }
     }
     OnColumnCreated(column, columnInfo);
     return column;
 }
Ejemplo n.º 5
0
 protected virtual void OnColumnCreated(LayoutViewColumn column, ColumnInfoNodeWrapper columnInfo) {
     if (ColumnCreated != null) {
         ColumnCreatedEventArgs args = new ColumnCreatedEventArgs(column, columnInfo);
         ColumnCreated(this, args);
     }
 }
Ejemplo n.º 6
0
 public CustomCreateColumnEventArgs(LayoutViewColumn column, ColumnInfoNodeWrapper columnInfo, RepositoryEditorsFactory repositoryFactory) {
     this.column = column;
     this.columnInfo = columnInfo;
     this.repositoryFactory = repositoryFactory;
 }