private void ProcessBoolean(IMemberInfo memberInfo, object objValue, IModelColumn columnModel, int RowNumber, ref String Value)
 {
     if ((Boolean)objValue)
     {
         Value = "<span class=\"glyphicon glyphicon-ok\"></span>";
     }
 }
        CriteriaOperator CriteriaSelectionOperator(ListView listView, IModelColumn filteredColumn)
        {
            var keyName = filteredColumn.ModelMember.MemberInfo.MemberTypeInfo.KeyMember.Name;

            return(listView.Editor is ISelectionCriteria selectionCriteria?CriteriaOperator.Parse(filteredColumn.PropertyName + "." + (selectionCriteria).SelectionCriteria.ToString())
                       : new InOperator(filteredColumn.PropertyName + "." + keyName, Getkeys(listView)));
        }
Exemple #3
0
        private void SetMemberValueOfItem(XPBaseObject item, IModelColumn column, ASPxEdit cellControl)
        {
            var edit = cellControl as ASPxSpinEdit;

            if (edit != null && edit.NumberType == SpinEditNumberType.Integer)
            {
                item.SetMemberValue(column.PropertyName,
                                    column.ModelMember.MemberInfo.MemberType == typeof(int)
                        ? Convert.ToInt32(cellControl.Value)
                        : Convert.ToInt64(cellControl.Value));
            }
            else
            {
                if (typeof(XPBaseObject).IsAssignableFrom(column.ModelMember.MemberInfo.MemberType) &&
                    !typeof(IFileData).IsAssignableFrom(column.ModelMember.MemberInfo.MemberType))
                {
                    object o = _objectSpace.GetObjectByKey(column.ModelMember.MemberInfo.MemberType, cellControl.Value);
                    item.SetMemberValue(column.PropertyName, o);
                }
                else
                {
                    item.SetMemberValue(column.PropertyName, cellControl.Value);
                }
            }
        }
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            var treeListEditor = View.Editor as TreeListEditor;

            if (treeListEditor != null)
            {
                _treeList = (ObjectTreeList)treeListEditor.TreeList;
                if (View.Model.AllowEdit)
                {
                    foreach (RepositoryItem ri in _treeList.RepositoryItems)
                    {
                        ri.ReadOnly = false;
                    }
                    foreach (var columnWrapper1 in treeListEditor.Columns)
                    {
                        var          columnWrapper = (TreeListColumnWrapper)columnWrapper1;
                        IModelColumn modelColumn   = View.Model.Columns[columnWrapper.PropertyName];
                        if (modelColumn != null)
                        {
                            columnWrapper.Column.OptionsColumn.AllowEdit = modelColumn.AllowEdit;
                        }
                    }
                    _treeList.CellValueChanged += treeList_CellValueChanged;
                    _treeList.ShownEditor      += treeList_ShownEditor;
                    _treeList.ShowingEditor    += TreeListOnShowingEditor;
                    _treeList.OptionsBehavior.ImmediateEditor = false;
                    _treeList.OptionsBehavior.Editable        = true;
                }
            }
        }
        public String FormatValue(IMemberInfo memberInfo, object objValue, IModelColumn columnModel, int RowNumber)
        {
            String Value = "";

            if (memberInfo != null && objValue != null)
            {
                if (objValue is System.Drawing.Bitmap)
                {
                    ProcessBitmap(memberInfo, objValue, columnModel, RowNumber, ref Value);
                }
                else
                if (objValue is Enum)
                {
                    ProcessEnum(memberInfo, objValue, columnModel, RowNumber, ref Value);
                }
                else
                if (objValue is Boolean)
                {
                    ProcessBoolean(memberInfo, objValue, columnModel, RowNumber, ref Value);
                }
                else
                if (objValue is Color)
                {
                    ProcessColor(memberInfo, objValue, columnModel, RowNumber, ref Value);
                }
                else
                {
                    ProcessDefault(memberInfo, objValue, columnModel, RowNumber, ref Value);
                }
            }
            return(Value);
        }
Exemple #6
0
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            // Access and customize the target View control.
            ASPxGridListEditor gridListEditor = View.Editor as ASPxGridListEditor;

            if (gridListEditor != null)
            {
                ASPxGridView gridView = gridListEditor.Grid;
                gridView.Settings.UseFixedTableLayout     = true;
                gridView.Settings.HorizontalScrollBarMode = ScrollBarMode.Auto;
                gridView.Width = Unit.Percentage(100);
                gridView.Style.Add("min-width", "1024px");
                foreach (WebColumnBase column in gridView.Columns)
                {
                    IColumnInfo columnInfo = ((IDataItemTemplateInfoProvider)gridListEditor).GetColumnInfo(column);
                    if (columnInfo != null)
                    {
                        IModelColumn modelColumn = (IModelColumn)columnInfo.Model;
                        if (columnInfo.Model.Index == -1)
                        {
                            column.Width = Unit.Percentage(0);
                        }
                        else
                        {
                            column.Width = Unit.Percentage(modelColumn.Width);
                        }
                    }
                }
            }
        }
        protected override GridViewDataColumn CreateColumn(IModelColumn columnInfo)
        {
            GridViewDataColumn gridViewDataColumnWithInfo = base.CreateColumn(columnInfo);

            OnColumnCreated(new ColumnCreatedEventArgs(gridViewDataColumnWithInfo));
            return(gridViewDataColumnWithInfo);
        }
        protected override void OnActivated()
        {
            base.OnActivated();
            string propertyName = "ModifiedOn";
            bool   demoFlag     = true;

            //Dennis: This code applies a client side sorting.
            if (demoFlag)
            {
                IModelColumn columnInfo = ((IModelList <IModelColumn>)View.Model.Columns)[propertyName];
                if (columnInfo != null)
                {
                    columnInfo.SortIndex = 0;
                    columnInfo.SortOrder = ColumnSortOrder.Descending;
                }
            }
            else
            {
                //Dennis: This code is used for the server side sorting.
                if (((IModelList <IModelSortProperty>)View.Model.Sorting)[propertyName] == null)
                {
                    IModelSortProperty sortProperty = View.Model.Sorting.AddNode <IModelSortProperty>(propertyName);
                    sortProperty.Direction    = SortingDirection.Descending;
                    sortProperty.PropertyName = propertyName;
                }
            }
        }
Exemple #9
0
 internal static void MapColumn(
     IModelColumn modelColumn,
     Column column
     )
 {
     if (column.Width.HasValue)
     {
         modelColumn.Width
             = column.Width ?? modelColumn.Width;
     }
     if (column.SortOrder.HasValue)
     {
         modelColumn.SortOrder
             = column.SortOrder ?? modelColumn.SortOrder;
     }
     if (column.SortIndex.HasValue)
     {
         modelColumn.SortIndex
             = column.SortIndex ?? modelColumn.SortIndex;
     }
     if (column.GroupIndex.HasValue)
     {
         modelColumn.GroupIndex
             = column.GroupIndex ?? modelColumn.GroupIndex;
     }
     if (column.GroupInterval.HasValue)
     {
         modelColumn.GroupInterval
             = column.GroupInterval ?? modelColumn.GroupInterval;
     }
 }
 protected virtual bool IsColumnSupported(IModelColumn model)
 {
     if (model.GroupIndex >= 0)
     {
         return(false);
     }
     return(supportedPropertyEditorTypes().Any(type => type.IsAssignableFrom(model.PropertyEditorType)));
 }
        private void ProcessDefault(IMemberInfo memberInfo, object objValue, IModelColumn columnModel, int RowNumber, ref String Value)
        {
            String displayFormat = "{0}";

            if (columnModel != null)
            {
                var valuePath = columnModel.GetValue <String>("FieldName").Split('.');
                if (!(objValue is XPBaseObject) && !(objValue is String) && !objValue.GetType().IsPrimitive)
                {
                    if (valuePath.Length > 1)
                    {
                        IMemberInfo mInfo;
                        var         val = ObjectFormatValues.GetValueRecursive(String.Join(".", valuePath.Skip(1).Take(valuePath.Length - 1)), objValue, out mInfo);
                        if (val != new object())
                        {
                            objValue = String.Concat(val);
                        }
                    }
                }

                if (String.Concat(columnModel.DisplayFormat) != "")
                {
                    displayFormat = columnModel.DisplayFormat;
                }
                else
                if (memberInfo.MemberTypeInfo != null)
                {
                    var attr = memberInfo.MemberTypeInfo.FindAttribute <ObjectCaptionFormatAttribute>();
                    if (attr != null)
                    {
                        displayFormat = attr.FormatString;
                        Value         = String.Format(new ObjectFormatter(), displayFormat, objValue);
                    }
                    else
                    {
                        var defPropAttr = memberInfo.MemberTypeInfo.FindAttribute <XafDefaultPropertyAttribute>();
                        if (defPropAttr != null)
                        {
                            displayFormat = attr.FormatString;
                            Value         = "{0:" + defPropAttr.Name + "}";
                            Value         = String.Format(new ObjectFormatter(), displayFormat, objValue);
                        }
                    }
                }
                ;
            }

            if (Value == "")
            {
                Value = String.Format(displayFormat, objValue);
            }

            if (memberInfo.MemberTypeInfo != null && memberInfo.MemberTypeInfo.IsDomainComponent && columnModel != null)
            {
                Value = String.Format(@"<a href=""javascript:;"" onclick=""event = event || window.event; event.stopPropagation(); {0}"">{1}</a>", Handler.GetScript(String.Format("'BrowseObject|{0}|{1}'", RowNumber, columnModel.PropertyName)), Value);
            }
        }
        private void ProcessColor(IMemberInfo memberInfo, object objValue, IModelColumn columnModel, int RowNumber, ref String Value)
        {
            var color = (Color)objValue;

            if (color != Color.Empty)
            {
                Value = String.Format("<div style='width: 20px; height: 20px; border: 1px solid; border-color: rgba(0,0,0,0.2); background: rgba({0},{1},{2},{3});' class='img-circle'><span style='padding-left: 24px'>{4}</span></div>", color.R, color.G, color.B, color.A / 255, ColorTranslator.ToHtml(color));
            }
        }
 protected override ITemplate CreateDataItemTemplate(IModelColumn columnInfo){
     if (IsColumnSupported(columnInfo)){
         var editModeTemplate =
             (EditModeDataItemTemplate) CreateDefaultColumnTemplate(columnInfo, this, ViewEditMode.Edit);
         editModeTemplate.PropertyEditor.ImmediatePostData = false;
         editModeTemplate.CustomCreateCellControl += editModeTemplate_CustomCreateCellControl;
         return editModeTemplate;
     }
     return base.CreateDataItemTemplate(columnInfo);
 }
        protected override ColumnWrapper AddColumnCore(IModelColumn columnInfo)
        {
            var columnWrapper = (ASPxGridViewColumnWrapper)base.AddColumnCore(columnInfo);

            if (IsColumnSupported((IModelColumn)columnWrapper.Column.Model(Model)))
            {
                columnWrapper.Column.Settings.AllowSort  = DefaultBoolean.False;
                columnWrapper.Column.Settings.AllowGroup = DefaultBoolean.False;
            }
            return(columnWrapper);
        }
Exemple #15
0
 protected override void OnColumnCreated(GridColumn column, IModelColumn columnInfo)
 {
     base.OnColumnCreated(column, columnInfo);
     if (column.ColumnEdit is RepositoryItemMemoExEdit)
     {
         column.ColumnEdit = new RepositoryItemMemoEdit {
             Name = columnInfo.PropertyName
         }
     }
     ;
 }
        public void acitvateSorter(string propertyname)
        {
            ListView curView = (ListView)View;

            IModelColumn columnInfo = ((IModelList <IModelColumn>)curView.Model.Columns)[propertyname];

            if (columnInfo != null)
            {
                columnInfo.SortIndex = 1;
                columnInfo.SortOrder = ColumnSortOrder.Ascending;
            }
        }
 protected override ITemplate CreateDataItemTemplate(IModelColumn columnInfo)
 {
     if (IsColumnSupported(columnInfo))
     {
         var editModeTemplate =
             (EditModeDataItemTemplate)CreateDefaultColumnTemplate(columnInfo, this, ViewEditMode.Edit);
         editModeTemplate.PropertyEditor.ImmediatePostData = false;
         editModeTemplate.CustomCreateCellControl         += editModeTemplate_CustomCreateCellControl;
         return(editModeTemplate);
     }
     return(base.CreateDataItemTemplate(columnInfo));
 }
 void RemoveDefaultColumns(IModelListView listViewInfo, IEnumerable <CustomQueryPropertyAttribute> customQueryPropertyAttributes)
 {
     for (int i = listViewInfo.Columns.Count; i > 0;)
     {
         i--;
         IModelColumn col   = listViewInfo.Columns[i];
         var          names = customQueryPropertyAttributes.Select(attribute => attribute.Name).ToArray();
         if (Array.IndexOf(names, col.Id) < 0)
         {
             col.Remove();
         }
     }
 }
Exemple #19
0
        private static (IModelColumn modelColumn, IModelPositionInListViewListViewItem item) PositionMember(this ListView listView)
        {
            var item = listView.Application().Model.ModelPositionInListView()
                       .ListViewItems.First(rule => rule.ListView.Id() == listView.Id);
            var modelColumn = listView.Model.Columns.FirstOrDefault(column => column.ModelMember == item.PositionMember);

            if (modelColumn == null)
            {
                modelColumn = listView.Model.Columns.AddNode <IModelColumn>();
                modelColumn.PropertyName = item.PositionMember.Name;
                modelColumn.Index        = -1;
            }
            return(modelColumn, item);
        }
 protected override void SetPreviewColumn(IModelColumn previewColumnModel) {
     var listView = (ListView)View;
     if (listView.Editor is IColumnViewEditor) {
         GridControl gridControl = ((IColumnViewEditor)listView.Editor).Grid;
         if (gridControl != null) {
             var gridView = gridControl.FocusedView as DevExpress.XtraGrid.Views.Grid.GridView;
             if (gridView != null) {
                 gridView.PreviewFieldName = previewColumnModel.PropertyName;
                 gridView.OptionsView.ShowPreview = true;
                 gridView.OptionsView.AutoCalcPreviewLineCount = true;
             }
         }
     }
 }
Exemple #21
0
        protected IModelColumn FindColumnModelByPropertyName(string propertyName)
        {
            IModelColumn columnInfo = null;

            foreach (IModelColumn colInfo in ListEditor.Model.Columns)
            {
                if (colInfo.PropertyName == propertyName)
                {
                    columnInfo = colInfo;
                    break;
                }
            }
            return(columnInfo);
        }
Exemple #22
0
        // Override to do something when a Controller is activated and its View is assigned.
        protected override void OnActivated()
        {
            base.OnActivated();
            //For instance, you can customize the current View and its editors (http://documentation.devexpress.com/#Xaf/CustomDocument2729) or manage the Controller's Actions visibility and availability (http://documentation.devexpress.com/#Xaf/CustomDocument2728).


            string propertyName = "FechaDoc";
            bool   demoFlag     = true;

            //Dennis: This code applies a client side sorting.
            if (demoFlag)
            {
                IModelColumn columnInfo = ((IModelList <IModelColumn>)((ListView)View).Model.Columns)[propertyName];
                if (columnInfo != null)
                {
                    columnInfo.SortIndex = 0;
                    columnInfo.SortOrder = ColumnSortOrder.Descending;
                }
            }
            else
            {
                //Dennis: This code is used for the server side sorting.
                if (((IModelList <IModelSortProperty>)((ListView)View).Model.Sorting)[propertyName] == null)
                {
                    IModelSortProperty sortProperty = ((ListView)View).Model.Sorting.AddNode <IModelSortProperty>(propertyName);
                    sortProperty.Direction    = SortingDirection.Descending;
                    sortProperty.PropertyName = propertyName;
                }
            }

            /*
             * if (!((Employee)SecuritySystem.CurrentUser).IsAdministrator)
             * {
             *  lv.CollectionSource.Criteria["AssignedTo"] = CriteriaOperator.Parse("AssignedTo.Oid = ?", SecuritySystem.CurrentUserId);
             * }*/

            UpdateAction();


            bool puede = SecuritySystem.CurrentUserName == "root";

            simpleActionRprtCntbl.Enabled.SetItemValue("SecurityAllowance", puede);
            simpleActionRprtCntbl.Active.SetItemValue("Visible", puede);

            /*
             * puede = false;
             * simpleActionGetXml.Enabled.SetItemValue("SecurityAllowance", puede);
             * simpleActionGetXml.Active.SetItemValue("Visible", puede);*/
        }
        protected override void OnActivated()
        {
            base.OnActivated();

            _positionColumn = ((IModelListViewPositionColumn)View.Model).PositionColumn;
            foreach (var action in Actions)
            {
                action.Active["PositionColumn"] = _positionColumn != null;
            }
            if (_positionColumn != null)
            {
                _memberInfo = _positionColumn.ModelMember.MemberInfo;
                View.Editor.DataSourceChanged += EditorOnDataSourceChanged;
            }
        }
Exemple #24
0
        public CriteriaOperator GetCriteria(IModelColumn modelColumn, object parameters, CriteriaOperator activeFilterCriteria)
        {
            var binaryOperator    = new BinaryOperator(modelColumn.PropertyName, parameters);
            var criteriaProcessor = new CriteriaContainsProcessor(activeFilterCriteria);

            if (!criteriaProcessor.Contains(binaryOperator))
            {
                if (ReferenceEquals(activeFilterCriteria, null))
                {
                    return(binaryOperator);
                }
                return(new GroupOperator(GroupOperatorType.And, activeFilterCriteria, binaryOperator));
            }
            return(activeFilterCriteria);
        }
Exemple #25
0
        public static ColumnChooser Create(IObjectSpace objectSpace, IModelColumn modelColumn, ColumnChooser parentColumnChooser)
        {
            var columnChooser = objectSpace.CreateObject <ColumnChooser>();

            columnChooser._modelColumn = modelColumn;
            columnChooser.Parent       = parentColumnChooser;
            columnChooser.Caption      = modelColumn.Caption;
            columnChooser.PropertyName = modelColumn.PropertyName;
            columnChooser.Key          = modelColumn.Id;
            if (parentColumnChooser != null)
            {
                columnChooser.PropertyName = $"{parentColumnChooser.PropertyName}.{columnChooser.PropertyName}";
                columnChooser.Key          = $"{parentColumnChooser.Key}.{columnChooser.Key}";
            }
            return(columnChooser);
        }
Exemple #26
0
        private void Grid_DataBound(object sender, System.EventArgs e)
        {
            genCon = Frame.GetController <GenController>();
            if (typeof(ClassDocument).IsAssignableFrom(View.ObjectTypeInfo.Type) ||
                typeof(ClassDocumentDetail).IsAssignableFrom(View.ObjectTypeInfo.Type) ||
                typeof(ClassStockTransferDocument).IsAssignableFrom(View.ObjectTypeInfo.Type) ||
                typeof(ClassStockTransferDocumentDetail).IsAssignableFrom(View.ObjectTypeInfo.Type)
                )
            {
                if (!genCon.GetCurrentUserViewPriceStatus())
                {
                    ASPxGridListEditor listEditor = View.Editor as ASPxGridListEditor;

                    if (listEditor != null)
                    {
                        foreach (GridViewColumn column in listEditor.Grid.VisibleColumns)
                        {
                            if (column is GridViewDataColumn)
                            {
                                GridViewDataColumn col = (GridViewDataColumn)column;
                                if (!string.IsNullOrEmpty(col.FieldName))
                                {
                                    try
                                    {
                                        IModelColumn mycol = View.Model.Columns[col.FieldName];
                                        if (mycol != null)
                                        {
                                            string temp = View.Model.Columns[col.FieldName].ModelMember.PropertyEditorType.Name;
                                            //if (temp == "MyDecPropertyEditorVP" || temp == "MyDouPropertyEditorVP")
                                            if (temp.Contains("PropertyEditorVP"))
                                            {
                                                column.Visible = false;
                                            }
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        protected override void OnActivated()
        {
            Type type = this.View.ObjectTypeInfo.Type;

            List <PropertyInfo> properties = type.GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(ListViewSort))).ToList();

            //Dennis: This code applies a client side sorting.
            foreach (PropertyInfo propertyInfo in properties)
            {
                IModelColumn columnInfo = ((IModelList <IModelColumn>)View.Model.Columns)[propertyInfo.Name];

                if (columnInfo != null)
                {
                    columnInfo.SortIndex = 0;
                    columnInfo.SortOrder = ((ListViewSort)propertyInfo.GetCustomAttribute(typeof(ListViewSort))).sortingDirection;
                }
            }
        }
 private void Editor_ModelApplied(object sender, EventArgs e)
 {
     if (sender is ASPxGridListEditor)
     {
         foreach (DevExpress.ExpressApp.Editors.ColumnWrapper columnWrapper in ((ASPxGridListEditor)sender).Columns)
         {
             ASPxGridViewColumnWrapper gridColumnWrapper = columnWrapper as ASPxGridViewColumnWrapper;
             if (gridColumnWrapper != null)
             {
                 IModelColumn modelColumn = (this.View as ListView)?.Model.Columns[gridColumnWrapper.PropertyName];
                 IModelMemberAutoFilterRow modelMember = modelColumn?.ModelMember as IModelMemberAutoFilterRow;
                 if (modelMember != null && modelMember.AutoFilterRowCondition.HasValue)
                 {
                     gridColumnWrapper.Column.Settings.AutoFilterCondition = TransformToAutoFilterCondition(modelMember.AutoFilterRowCondition.Value);
                 }
             }
         }
     }
 }
Exemple #29
0
        protected override void OnActivated()
        {
            filteringCriterionAction.Items.Clear();
            foreach (CriteriosDeFiltro criterion in ObjectSpace.GetObjects <CriteriosDeFiltro>())
            {
                if (criterion.TipodeDatos.IsAssignableFrom(View.ObjectTypeInfo.Type))
                {
                    filteringCriterionAction.Items.Add(
                        new ChoiceActionItem(criterion.Descripcion, criterion.Criterio));
                }
            }
            if (filteringCriterionAction.Items.Count > 0)
            {
                filteringCriterionAction.Items.Add(new ChoiceActionItem("Todos los Registros", null));
            }

            string   propertyName = "Fecha";
            ListView vw           = null;

            if (View.GetType().ToString().Contains("VST") == false)
            {
                if (View.GetType().ToString().Contains("ListView"))
                {
                    if (View.GetType().ToString().Contains("Collection") == false)
                    {
                        vw = View as XpandListView;
                        IModelColumn columnInfo = ((IModelList <IModelColumn>)vw.Model.Columns)[propertyName];
                        if (columnInfo != null)
                        {
                            filteringCriterionAction.Items.Clear();
                            filteringCriterionAction.Items.Add(new ChoiceActionItem("Este Mes", "GetMonth([Fecha]) = GetMonth(Now()) AND GetYear([Fecha])=GetYear(Now())"));
                            filteringCriterionAction.Items.Add(new ChoiceActionItem("Este Mes y Mes Pasado", "GetMonth([Fecha]) >= GetMonth(Now())-1 AND GetMonth([Fecha]) <= GetMonth(Now()) AND GetYear([Fecha])=GetYear(Now())"));
                            filteringCriterionAction.Items.Add(new ChoiceActionItem("Este Año", "GetYear([Fecha])=GetYear(Now())"));
                            filteringCriterionAction.Items.Add(new ChoiceActionItem("Todos los Registros", ""));
                            //Quita los demas registros es a nivel de datasource
                            //View.CollectionSource.Criteria["Este Mes"] = CriteriaOperator.Parse("GetMonth([Fecha])=GetMonth(Now()) and GetYear([Fecha])=GetYear(Now())");
                            filteringCriterionAction.SelectedIndex = 0;
                            filteringCriterionAction.DoExecute(filteringCriterionAction.SelectedItem);
                        }
                    }
                }
            }
        }
        protected override void AddColumn(string propertyName)
        {
            IModelColumn columnInfo = FindColumnModelByPropertyName(propertyName);

            if (columnInfo == null)
            {
                columnInfo              = ((ListView)View).Model.Columns.AddNode <IModelColumn>();
                columnInfo.Id           = propertyName;
                columnInfo.PropertyName = propertyName;
                columnInfo.Index        = -1;
                GridEditor.AddColumn(columnInfo);
            }
            else
            {
                throw new Exception(SystemExceptionLocalizer.GetExceptionMessage(
                                        ExceptionId.CannotAddDuplicateProperty, propertyName));
            }
            gridView.CustomizationForm.CheckAndUpdate();
        }
Exemple #31
0
        protected override void SetPreviewColumn(IModelColumn previewColumnModel)
        {
            var listView = (ListView)View;

            if (listView.Editor is IColumnViewEditor)
            {
                GridControl gridControl = ((IColumnViewEditor)listView.Editor).Grid;
                if (gridControl != null)
                {
                    var gridView = gridControl.FocusedView as DevExpress.XtraGrid.Views.Grid.GridView;
                    if (gridView != null)
                    {
                        gridView.PreviewFieldName        = previewColumnModel.PropertyName;
                        gridView.OptionsView.ShowPreview = true;
                        gridView.OptionsView.AutoCalcPreviewLineCount = true;
                    }
                }
            }
        }
        private void Bestfit_Execute(object sender, DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs e)
        {
            ASPxGridListEditor gridListEditor = View.Editor as ASPxGridListEditor;

            if (gridListEditor != null)
            {
                ASPxGridView gridView = gridListEditor.Grid;
                gridView.Settings.UseFixedTableLayout     = true;
                gridView.Settings.HorizontalScrollBarMode = ScrollBarMode.Auto;
                gridView.Width = Unit.Percentage(100);
                foreach (WebColumnBase column in gridView.Columns)
                {
                    IColumnInfo columnInfo = ((IDataItemTemplateInfoProvider)gridListEditor).GetColumnInfo(column);
                    if (columnInfo != null)
                    {
                        IModelColumn modelColumn = (IModelColumn)columnInfo.Model;
                        column.Width = Unit.Pixel(200);
                    }
                }
            }
        }
 protected virtual bool IsColumnSupported(IModelColumn model){
     if (model.GroupIndex >= 0){
         return false;
     }
     return supportedPropertyEditorTypes().Any(type => type.IsAssignableFrom(model.PropertyEditorType));
 }
 protected override ColumnWrapper AddColumnCore(IModelColumn columnInfo) {
     var column = CreateGridColumn();
     GridView.Columns.Add((GridColumn)column);
     IMemberInfo memberInfo = FindMemberInfoForColumn(columnInfo);
     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.OptionsColumn.AllowSort = DefaultBoolean.True;
             column.OptionsColumn.AllowGroup = DefaultBoolean.True;
         }
         if (SimpleTypes.IsClass(memberInfo.MemberType) || memberInfo.MemberType.IsInterface) {
             column.FilterMode = ColumnFilterMode.DisplayText;
         } else {
             column.FilterMode = ColumnFilterMode.Value;
         }
     } else {
         column.FieldName = columnInfo.PropertyName;
     }
     ApplyModel(column, columnInfo);
     if (memberInfo != null) {
         if (repositoryFactory != null) {
             RepositoryItem repositoryItem = null;
             if (IsReplacedColumnByAsyncServerMode(columnInfo.PropertyName)) {
                 MemberEditorInfoCalculator calculator = new MemberEditorInfoCalculator();
                 Type editorType = calculator.GetEditorType(Model.ModelClass.FindMember(memberInfo.Name));
                 IInplaceEditSupport propertyEditor = Activator.CreateInstance(editorType, ObjectType, columnInfo) as IInplaceEditSupport;
                 repositoryItem = propertyEditor != null ? ((IInplaceEditSupport)propertyEditor).CreateRepositoryItem() : null;
             } else {
                 repositoryItem = repositoryFactory.CreateRepositoryItem(false, columnInfo, ObjectType);
             }
             if (repositoryItem != null) {
                 grid.RepositoryItems.Add(repositoryItem);
                 repositoryItem.EditValueChanging += new ChangingEventHandler(repositoryItem_EditValueChanging);
                 column.ColumnEdit = repositoryItem;
                 column.OptionsColumn.AllowEdit = IsDataShownOnDropDownWindow(repositoryItem) ? true : AllowEdit;
                 column.AppearanceCell.Options.UseTextOptions = true;
                 column.AppearanceCell.TextOptions.HAlignment = WinAlignmentProvider.GetAlignment(memberInfo.MemberType);
                 repositoryItem.ReadOnly |= !AllowEdit || ReadOnlyEditors;
                 if (Model.UseServerMode || (columnInfo.ModelMember.Type.IsInterface && !typeof(IComparable).IsAssignableFrom(memberInfo.MemberType))) {
                     column.FieldNameSortGroup = new ObjectEditorHelperBase(XafTypesInfo.Instance.FindTypeInfo(columnInfo.ModelMember.Type), columnInfo).GetFullDisplayMemberName(columnInfo.PropertyName);
                 }
                 if (repositoryItem is ILookupEditRepositoryItem) {
                     column.FilterMode = LookupColumnFilterMode;
                     if (LookupColumnFilterMode == ColumnFilterMode.Value) {
                         column.OptionsFilter.AutoFilterCondition = AutoFilterCondition.Equals;
                         column.OptionsFilter.FilterBySortField = DefaultBoolean.False;
                     } else {
                         column.OptionsFilter.FilterBySortField = DefaultBoolean.True;
                     }
                 }
                 if (repositoryItem is RepositoryItemMemoExEdit) {
                     column.OptionsColumn.AllowGroup = column.OptionsColumn.AllowSort = DefaultBoolean.True;
                 }
                 if ((repositoryItem is RepositoryItemPictureEdit) && (((RepositoryItemPictureEdit)repositoryItem).CustomHeight > 0)) {
                     GridView.OptionsView.RowAutoHeight = true;
                 }
                 if (repositoryItem is RepositoryItemRtfEditEx) {
                     column.FilterMode = ColumnFilterMode.DisplayText;
                 }
                 if (!repositoryItem.DisplayFormat.IsEmpty) {
                     column.DisplayFormat.FormatType = repositoryItem.DisplayFormat.FormatType;
                     column.DisplayFormat.Format = repositoryItem.DisplayFormat.Format;
                     column.DisplayFormat.FormatString = repositoryItem.DisplayFormat.FormatString;
                 }
             }
         }
         if ((column.ColumnEdit == null) && !typeof(IList).IsAssignableFrom(memberInfo.MemberType)) {
             column.OptionsColumn.AllowEdit = false;
             column.FieldName = GetDisplayablePropertyName(columnInfo.PropertyName);
         }
     }
     OnColumnCreated((GridColumn)column, columnInfo);
     if (!grid.IsLoading && gridView.DataController.Columns.GetColumnIndex(column.FieldName) == -1) {
         gridView.DataController.RePopulateColumns();
     }
     return CreateGridColumnWrapper(column);
 }
 protected override void ApplyModel(IXafGridColumn column, IModelColumn columnInfo) {
     var xAdvBandedGridColumn = column;
     xAdvBandedGridColumn.ApplyModel(columnInfo);
 }
 protected override void OnColumnCreated(GridColumn column, IModelColumn columnInfo) {
     base.OnColumnCreated(column, columnInfo);
     if (column.ColumnEdit is RepositoryItemMemoExEdit)
         column.ColumnEdit = new RepositoryItemMemoEdit { Name = columnInfo.PropertyName };
 }
 public ColumnCreatedEventArgs(LayoutViewColumn column, IModelColumn columnInfo) {
     this.column = column;
     this.columnInfo = columnInfo;
 }
 private void RefreshColumn(IModelColumn frameColumn, LayoutViewColumn column) {
     column.Caption = frameColumn.Caption;
     if (string.IsNullOrEmpty(column.Caption)) {
         column.Caption = column.FieldName;
     }
     column.LayoutViewField.ColumnName = column.Caption;
     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;
     if (column.VisibleIndex != frameColumn.Index) {
         column.VisibleIndex = frameColumn.Index;
     }
     
     column.SummaryItem.SummaryType = (SummaryItemType)Enum.Parse(typeof(SummaryItemType), frameColumn.SummaryType.ToString());
 }
 protected virtual void OnColumnCreated(LayoutViewColumn column, IModelColumn columnInfo) {
     if (ColumnCreated != null) {
         ColumnCreatedEventArgs args = new ColumnCreatedEventArgs(column, columnInfo);
         ColumnCreated(this, args);
     }
 }
 protected abstract void ApplyModel(IXafGridColumn column, IModelColumn columnInfo);
Exemple #41
0
 public void ApplyModel(IModelColumn columnInfo) {
     _model = (IModelColumnOptionsAdvBandedView)columnInfo;
     CreateModelSynchronizer().ApplyModel();
 }
 public void ApplyModel(IModelColumn columnInfo) {
     _model = columnInfo;
     CreateModelSynchronizer().ApplyModel();
 }
 protected override ColumnWrapper AddColumnCore(IModelColumn columnInfo){
     var columnWrapper = (ASPxGridViewColumnWrapper) base.AddColumnCore(columnInfo);
     if (IsColumnSupported((IModelColumn) columnWrapper.Column.Model(Model))){
         columnWrapper.Column.Settings.AllowSort = DefaultBoolean.False;
         columnWrapper.Column.Settings.AllowGroup = DefaultBoolean.False;
     }
     return columnWrapper;
 }
 protected virtual void OnColumnCreated(GridColumn column, IModelColumn columnInfo) {
     if (ColumnCreated != null) {
         var args = new ColumnCreatedEventArgs(column, columnInfo);
         ColumnCreated(this, args);
     }
 }
 private IMemberInfo FindMemberInfoForColumn(IModelColumn columnInfo) {
     if (IsReplacedColumnByAsyncServerMode(columnInfo.PropertyName)) {
         return ObjectTypeInfo.FindMember(GetDisplayablePropertyName(columnInfo.PropertyName));
     }
     return ObjectTypeInfo.FindMember(columnInfo.PropertyName);
 }
 public LayoutViewColumn AddColumn(IModelColumn columnInfo) {
     if (columnsProperties.ContainsValue(columnInfo.PropertyName)) {
         throw new ArgumentException(string.Format(SystemExceptionLocalizer.GetExceptionMessage(ExceptionId.GridColumnExists), columnInfo.PropertyName), "ColumnInfo");
     }
     
     LayoutViewColumn column = new LayoutViewColumn();
     columnsProperties.Add(column, columnInfo.PropertyName);
     LayoutView.Columns.Add(column);
     
         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, columnInfo, 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;
 }
 private void SetMemberValueOfItem(XPBaseObject item, IModelColumn column, ASPxEdit cellControl){
     if (cellControl is ASPxSpinEdit && ((ASPxSpinEdit) cellControl).NumberType == SpinEditNumberType.Integer)
         item.SetMemberValue(column.PropertyName,
             column.ModelMember.MemberInfo.MemberType == typeof (int)
                 ? Convert.ToInt32(cellControl.Value)
                 : Convert.ToInt64(cellControl.Value));
     else{
         if (typeof (XPBaseObject).IsAssignableFrom(column.ModelMember.MemberInfo.MemberType) &&
             !typeof (IFileData).IsAssignableFrom(column.ModelMember.MemberInfo.MemberType)){
             object o = _objectSpace.GetObjectByKey(column.ModelMember.MemberInfo.MemberType, cellControl.Value);
             item.SetMemberValue(column.PropertyName, o);
         }
         else{
             item.SetMemberValue(column.PropertyName, cellControl.Value);
         }
     }
 }
        private ASPxEdit GetControlForColumn(IModelColumn column, XPBaseObject item){
            object value = item.GetMemberValue(column.PropertyName);
            ASPxEdit c;
            if (typeof (XPBaseObject).IsAssignableFrom(column.ModelMember.MemberInfo.MemberType)){
                c = RenderHelper.CreateASPxComboBox();
                var helper = new WebLookupEditorHelper(_application, _objectSpace,
                    column.ModelMember.MemberInfo.MemberTypeInfo, column);

                ((ASPxComboBox) c).ClientSideEvents.KeyUp =
                    "function(s, e) { if(e.htmlEvent.keyCode == 46){ s.SetSelectedIndex(-1); } }";
                ((ASPxComboBox) c).ValueType = column.ModelMember.MemberInfo.MemberTypeInfo.KeyMember.MemberType;
                ((ASPxComboBox) c).SelectedIndexChanged += DetailItemControlValueChanged;
                c.Style.Add("min-width", "120px");
                c.Width = new Unit(100, UnitType.Percentage);

                FillEditorValues(value, ((ASPxComboBox) c), helper, item, column.ModelMember);
                if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                    ((ASPxComboBox) c).ClientSideEvents.SelectedIndexChanged = "function(s, e) { " + "CallbackPanel" +
                                                                               Model.Id + ".PerformCallback(\"changed_" +
                                                                               column.PropertyName + "_" +
                                                                               item.GetMemberValue(
                                                                                   Model.ModelClass.KeyProperty) +
                                                                               "\"); }";
            }
            else if (typeof (Enum).IsAssignableFrom(column.ModelMember.MemberInfo.MemberType)){
                c = RenderHelper.CreateASPxComboBox();
                ((ASPxComboBox) c).ClientSideEvents.KeyUp =
                    "function(s, e) { if(e.htmlEvent.keyCode == 46){ s.SetSelectedIndex(-1); } }";
                var descriptor = new EnumDescriptor(column.ModelMember.MemberInfo.MemberType);
                var source = (Enum.GetValues(column.ModelMember.MemberInfo.MemberType).Cast<object>()
                    .Select(v => new Tuple<object, string>(v, descriptor.GetCaption(v)))).ToList();
                c.DataSource = source;
                ((ASPxComboBox) c).ValueField = "Item1";
                ((ASPxComboBox) c).TextField = "Item2";
                ((ASPxComboBox) c).ValueType = column.ModelMember.MemberInfo.MemberType;
                ((ASPxComboBox) c).SelectedIndexChanged += DetailItemControlValueChanged;
                c.Style.Add("min-width", "120px");
                c.Width = new Unit(100, UnitType.Percentage);
                c.Load += c_Load;
                if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                    ((ASPxComboBox) c).ClientSideEvents.SelectedIndexChanged = "function(s, e) { " + "CallbackPanel" +
                                                                               Model.Id + ".PerformCallback(\"changed_" +
                                                                               column.PropertyName + "_" +
                                                                               item.GetMemberValue(
                                                                                   Model.ModelClass.KeyProperty) +
                                                                               "\"); }";
            }
            else{
                switch (column.ModelMember.MemberInfo.MemberType.ToString()){
                    case "System.Boolean":
                    case "System.bool":
                        c = RenderHelper.CreateASPxCheckBox();
                        ((ASPxCheckBox) c).CheckedChanged += DetailItemControlValueChanged;
                        c.Style.Add("max-width", "20px");
                        if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                            ((ASPxCheckBox) c).ClientSideEvents.CheckedChanged = "function(s, e) { " + "CallbackPanel" +
                                                                                 Model.Id +
                                                                                 ".PerformCallback(\"changed_" +
                                                                                 column.PropertyName + "_" +
                                                                                 item.GetMemberValue(
                                                                                     Model.ModelClass.KeyProperty) +
                                                                                 "\"); }";
                        break;
                    case "System.String":
                    case "System.string":
                        c = RenderHelper.CreateASPxTextBox();
                        ((ASPxTextBox) c).MaxLength = 100;
                        if (column.ModelMember.Size > 0)
                            ((ASPxTextBox) c).MaxLength = column.ModelMember.Size;
                        ((ASPxTextBox) c).TextChanged += DetailItemControlValueChanged;
                        if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                            ((ASPxTextBox) c).ClientSideEvents.TextChanged = "function(s, e) { " + "CallbackPanel" +
                                                                             Model.Id + ".PerformCallback(\"changed_" +
                                                                             column.PropertyName + "_" +
                                                                             item.GetMemberValue(
                                                                                 Model.ModelClass.KeyProperty) +
                                                                             "\"); }";
                        c.Style.Add("min-width", "130px");
                        break;
                    case "System.Int32":
                    case "System.int":
                    case "System.Int64":
                    case "System.long":
                        c = RenderHelper.CreateASPxSpinEdit();
                        ((ASPxSpinEdit) c).NumberType = SpinEditNumberType.Integer;
                        ((ASPxSpinEdit) c).DecimalPlaces = 0;
                        c.ValueChanged += DetailItemControlValueChanged;
                        if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                            ((ASPxSpinEdit) c).ClientSideEvents.NumberChanged = "function(s, e) { " + "CallbackPanel" +
                                                                                Model.Id + ".PerformCallback(\"changed_" +
                                                                                column.PropertyName + "_" +
                                                                                item.GetMemberValue(
                                                                                    Model.ModelClass.KeyProperty) +
                                                                                "\"); }";
                        c.Style.Add("min-width", "100px");
                        break;
                    case "System.Double":
                    case "System.double":
                    case "System.Decimal":
                    case "System.decimal":
                    case "System.Nullable`1[System.Decimal]":
                        c = RenderHelper.CreateASPxSpinEdit();
                        ((ASPxSpinEdit) c).NumberType = SpinEditNumberType.Float;
                        string format = column.ModelMember.DisplayFormat;
                        if (format == "{0:C}") format = null;
                        ((ASPxSpinEdit) c).DisplayFormatString = format;
                        if (string.IsNullOrEmpty(format))
                            ((ASPxSpinEdit) c).DecimalPlaces = 2;
                        c.ValueChanged += DetailItemControlValueChanged;
                        if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                            ((ASPxSpinEdit) c).ClientSideEvents.NumberChanged = "function(s, e) { " + "CallbackPanel" +
                                                                                Model.Id + ".PerformCallback(\"changed_" +
                                                                                column.PropertyName + "_" +
                                                                                item.GetMemberValue(
                                                                                    Model.ModelClass.KeyProperty) +
                                                                                "\"); }";
                        c.Style.Add("min-width", "100px");
                        break;
                    case "System.DateTime":
                        c = RenderHelper.CreateASPxDateEdit();
                        ((ASPxDateEdit) c).DateChanged += DetailItemControlValueChanged;
                        if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                            ((ASPxDateEdit) c).ClientSideEvents.DateChanged = "function(s, e) { " + "CallbackPanel" +
                                                                              Model.Id + ".PerformCallback(\"changed_" +
                                                                              column.PropertyName + "_" +
                                                                              item.GetMemberValue(
                                                                                  Model.ModelClass.KeyProperty) +
                                                                              "\"); }";
                        c.Style.Add("min-width", "90px");

                        break;
                    default:
                        c = RenderHelper.CreateASPxTextBox();
                        ((ASPxTextBox) c).MaxLength = 100;
                        ((ASPxTextBox) c).TextChanged += DetailItemControlValueChanged;
                        if (column.ModelMember.MemberInfo.FindAttribute<ImmediatePostDataAttribute>() != null)
                            ((ASPxTextBox) c).ClientSideEvents.TextChanged = "function(s, e) { " + "CallbackPanel" +
                                                                             Model.Id + ".PerformCallback(\"changed_" +
                                                                             column.PropertyName + "_" +
                                                                             item.GetMemberValue(
                                                                                 Model.ModelClass.KeyProperty) +
                                                                             "\"); }";
                        c.Style.Add("min-width", "130px");
                        break;
                }
                c.Width = new Unit(100, UnitType.Percentage);
            }

            SetValueToControl(value, c);
            _controls.Add(c);

            OnControlCreated(column.PropertyName, c, item);

            return c;
        }
 protected override GridViewDataColumn CreateColumn(IModelColumn columnInfo) {
     GridViewDataColumn gridViewDataColumnWithInfo = base.CreateColumn(columnInfo);
     OnColumnCreated(new ColumnCreatedEventArgs(gridViewDataColumnWithInfo));
     return gridViewDataColumnWithInfo;
 }
 public override void ApplyModel(IModelColumn columnInfo) {
     base.ApplyModel(columnInfo);
     column.ApplyModel(columnInfo);
 }